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

Having trouble saving files to a specific location

3 Answers 52 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Adam
Top achievements
Rank 1
Adam asked on 04 Jul 2013, 06:19 PM
I have a form that has the following workflow.

1. user fills out form, including optionally uploading a file
2. the information gets saved to the database
3. using the ID of the entry, a new folder is created with that ID number
4. the file is uploaded to that folder
5. the user is redirected to another page

I can't seem to place the file uploading process in the right place.  Can someone point me in the right direction of the method to use?  Should I move the files in the button click action? Page load? onFileUpload?  

3 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 05 Jul 2013, 07:59 AM
Hello,

<telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server" TemporaryFolder="TempFiles">
  </telerik:RadAsyncUpload>
  <asp:Button ID="Button1" runat=server Text="Button" onclick="Button1_Click" />

protected void Button1_Click(object sender, EventArgs e)
   {
       //Perform insert operation and generate the ID
 
       string strID = "1";
 
       foreach (UploadedFile up in RadAsyncUpload1.UploadedFiles)
       {  
           DirectoryInfo dinfo = new DirectoryInfo(Server.MapPath("SpecificLocation/" + strID));
           dinfo.Create();
 
           up.SaveAs(Server.MapPath("SpecificLocation/" + strID)+"/"+ up.FileName);
       }
   }



Thanks,
Jayesh Goyani
0
Adam
Top achievements
Rank 1
answered on 05 Jul 2013, 12:54 PM
I think the issue I had ended up being that I was including a TargetFolder parameter in the RadAsyncUploader control, which was giving me an error when I tried doing the SaveAs bit.
0
Jayesh Goyani
Top achievements
Rank 2
answered on 08 Jul 2013, 08:55 AM
Hello,

can you please provide error detail?

Thanks,
Jayesh Goyani
Tags
AsyncUpload
Asked by
Adam
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Adam
Top achievements
Rank 1
Share this question
or