Use RadUpload to trasfer to FTP site

Thread is closed for posting
4 posts, 0 answers
  1. Jason
    Jason avatar
    1 posts
    Member since:
    Jul 2010

    Posted 08 Jul 2010 Link to this post

    I have been looking through the support topics and the online documentation but can't seem to find any information.  Can I use the RadUpload to transfer files to an FTP server instead of using the TargetFolder option?

    Thanks,
    - Jason
  2. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1596 posts

    Posted 12 Jul 2010 Link to this post

    Hello Jason,

    RadUpload does not provide such functionality. It serves the task of uploading files from the client to the server. You can then send the uploaded files to a ftp server or insert them into a database. We have prepared a demo showing how to insert the uploaded files directly into a database, without first saving them to the server. The demo uses RadAsyncUpload and the selected files are uploaded to a dedicated handler. I think it might be useful for you. You can find the demo here.

    All the best,
    Genady Sergeev
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mohammad
    Mohammad avatar
    2 posts
    Member since:
    Jun 2015

    Posted 27 Aug 2015 in reply to Genady Sergeev Link to this post

    this demo link is not working...please help me.. i am trying to save file directly to ftp...!!
  5. Nencho
    Admin
    Nencho avatar
    1457 posts

    Posted 01 Sep 2015 Link to this post

    Hello Mohammad,

    The online demo, referenced in the previous reply is no longer available. However, please consider the below implementation, using the FileUploaded event handler of the control:

    protected void AsyncFileUpload1_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e)
       {
           string ftp = "ftp://ftpadress.com";
           string username = "username123";
           string password = "password123";
            
           UploadToFtp(e.File, ftp, username, password);
       }
     
       public void UploadToFtp(UploadedFile file, string url, string username, string password)
       {
           var request = (FtpWebRequest)WebRequest.Create(new Uri(url + file.FileName));
     
           request.Method = WebRequestMethods.Ftp.UploadFile;
           request.UsePassive = false;
           request.Credentials = new NetworkCredential(username, password);
           request.ContentLength = file.ContentLength;
     
           var requestStream = request.GetRequestStream();
           byte[] bytes = new byte[file.InputStream.Length];
           file.InputStream.Read(bytes, 0, bytes.Length);
     
           requestStream.Write(bytes, 0, (int)file.ContentLength);
           requestStream.Close();
     
           var response = (FtpWebResponse)request.GetResponse();
     
           if (response != null)
               response.Close();
       }



    Regards,
    Nencho
    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
Back to Top