This is a migrated thread and some comments may be shown as answers.

Modify Filename and Insert Into DB Issue

5 Answers 48 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 22 Sep 2015, 09:37 PM

I'm having  a hard time wrapping my brain around this one!  The AsyncUpload is going to be part of a form that captures other information about the document. The file will be uploaded to the server and a new record is inserted into the database. As part of this, I am also modifying the filename.

My issue is that the file is moving out of the temporary location before any of the service side code is run. It IS uploaded OK and moving to the right folder. But it is doing it immediately at the form's submit button click so I am unable to change it's filename. This then causes my script to error out because it can't find the temporary file (it is already removed).

I'm sure this is a rookie question! But please take a look at this code. Thanks!

 

    protected void btnDocUpload_Click(object sender, EventArgs e)
    {
        foreach (UploadedFile file in RadAsyncUpload1.UploadedFiles)
        {
            //we are going to rename the file with the Catnumber + the date
            string newDocName = txtCatNumber.Text + DateTime.Now.ToString("M-d-yyyy");

    docBL doc = new docBL();
            doc.DocumentUpload(txtCatNumber.Text, newDocName);

            file.SaveAs("_SDFiles_\\" + newDocName + file.GetExtension(), true);
        }
    }

5 Answers, 1 is accepted

Sort by
0
Ralf
Top achievements
Rank 1
answered on 23 Sep 2015, 11:50 AM

Hi Matt,

 just as a hint: You do know that you can control where the control saves the file temporary and where to move it to after a successful processing ?

Check last 2 options in the markup:
<telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server" MultipleFileSelection="Disabled"  MaxFileInputsCount="1" Skin="Bootstrap"  TargetFolder="C:\temp\
" TemporaryFolder="c:\mytemp\"></telerik:RadAsyncUpload>

BR,

Ralf

0
Accepted
Hristo Valyavicharski
Telerik team
answered on 25 Sep 2015, 07:30 AM
Hi Matt,

Make sure that the TargetFolder property is NOT defined.

Regards,
Hristo Valyavicharski
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Matt
Top achievements
Rank 1
answered on 28 Sep 2015, 01:23 PM

Thanks - I DID have the TargetFolder assigned in the properties. Removing that solved my issue. And thanks, Ralf - I will explore the post-processing move property as well.

Can the target folder be relative? Or does it have to be an absolute path? My Production server's file paths would be a little different.

0
Hristo Valyavicharski
Telerik team
answered on 29 Sep 2015, 10:59 AM
The path can be relative, but Virtual Folders cannot be used.

Regards,
Hristo Valyavicharski
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Matt
Top achievements
Rank 1
answered on 29 Sep 2015, 06:42 PM

This post helped me solve my problem with uploading to a relative path folder. Thanks.

http://www.telerik.com/forums/a-simple-upload-and-save-file-in-a-folder#pKDBdy2azUelc2m6hfbi1Q

 ‚Äč

Tags
AsyncUpload
Asked by
Matt
Top achievements
Rank 1
Answers by
Ralf
Top achievements
Rank 1
Hristo Valyavicharski
Telerik team
Matt
Top achievements
Rank 1
Share this question
or