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

Use RadUpload to trasfer to FTP site

3 Answers 152 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 1
Jason asked on 08 Jul 2010, 04:47 PM
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

3 Answers, 1 is accepted

Sort by
0
Genady Sergeev
Telerik team
answered on 12 Jul 2010, 02:08 PM
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
0
Mohammad
Top achievements
Rank 1
answered on 27 Aug 2015, 07:48 AM
this demo link is not working...please help me.. i am trying to save file directly to ftp...!!
0
Nencho
Telerik team
answered on 01 Sep 2015, 08:57 AM
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
Tags
Upload (Obsolete)
Asked by
Jason
Top achievements
Rank 1
Answers by
Genady Sergeev
Telerik team
Mohammad
Top achievements
Rank 1
Nencho
Telerik team
Share this question
or