0

I'm having an issue saving files to physical directories based on a sql query. I've figured out that i has to do with setting the TargetPhysicalFolder in the aspx, I cannot leave this blank.
Inside of the aspx.cs i tried setting the TargetPhysicalFolder however this does not save the file.

RadUpload1.TargetPhysicalFolder = TargetFolderUpload;

but if I changed the aspx to be TargetPhysicalFolder = "C:\" it will save the file. How do I on the front side code change the TargetPhysicalFolder?

<telerik:RadUpload ID="RadUpload1" runat="server" TargetPhysicalFolder="?????"/>                        

2 Answers2

0

You can do it by:

foreach( var item in  RadUpload1.UploadedFiles)
{
  item.SaveAs("yourpath");
}

Documentation: http://www.telerik.com/help/aspnet-ajax/p_telerik_web_ui_radupload_uploadedfiles.html

Icarus
  • 63,293
  • 14
  • 100
  • 115
0

If you're basing it on SQL the overall solution would be similar to:

protected void Button1_Click(object sender, EventArgs e)
{
   if(some conditional goes here to dictate one folder)
   {
      foreach (Telerik.Web.UI.UploadedFile item in RadUpload1.UploadedFiles)
      {
         item.SaveAs(FirstPathGoesHere);
      }
   }
   else
   {
      foreach (Telerik.Web.UI.UploadedFile item in RadUpload1.UploadedFiles)
      {
         item.SaveAs(SecondPathGoesHere);
      }
}

If your application pool is set to anything other than LocalSystem, you may get a error "Access to the path '' is denied." Just a heads up.

KreepN
  • 8,528
  • 1
  • 40
  • 58