How To upload in Multiple Location with single RadAsyncUpload

2 posts, 0 answers
  1. Jaya
    Jaya avatar
    81 posts
    Member since:
    Mar 2011

    Posted 17 Oct 2014 Link to this post


    Hi

    Through Telerik's controls i found difficult to use UploadControl to work with multiple target folders 

    This is My Code I tried Like this

    Client Side Code
    ==============
      <telerik:RadAsyncUpload id="Rad1" runat="server" />

     foreach (UploadedFile f in Rad1.UploadedFiles)
                    {
                        f.SaveAs(DocSLoc + f.GetName() ;
                      }

    When I try with the above code I am getting the following error
    E:\MyApp\App_Data\RadUploadTemp\1413543533059HomeError.jpg 



  2. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1746 posts

    Posted 22 Oct 2014 Link to this post

    Hello,

    Please try the following approach:
    //code behind
    protected void RadAsyncUpload1_FileUploaded(object sender, FileUploadedEventArgs e)
        {
             
                if (e.File.GetExtension() == ".jpg")
                {
                    e.File.SaveAs(Server.MapPath("~/App_Data/CustomFolder1/") + e.File.FileName);
                }
                else
                {
                    e.File.SaveAs(Server.MapPath("~/App_Data/CustomFolder2/") + e.File.FileName);
                }
             
        }

    Please note that you do not need the foreach operation since this event will be fired for each uploaded file any way.



    Regards,
    Boyan Dimitrov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top