Upload large files through FTP in ASP.Net Shared Hosting

Last Reply on Jan 14, 2014 11:31 PM By Ikramshams

Posted on Jan 13, 2014 03:02 AM

I am uploading file through ftp using asp.net,c#. If my file size is small(3 MB) then it is uploading file bit if my file size is large then it is not uploading all file. it is uploading only about 3500 kb. i am using the following code. 

try
        {
            string Path = Server.MapPath("~");
            string filename = System.IO.Path.GetFileName(fImage1.PostedFile.FileName);
            string ftpfullpath = ftpurl + filename;
            FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create(ftpfullpath);
            ftp.Credentials = new NetworkCredential(ftpusername, ftppassword);
            ftp.KeepAlive = true;
            ftp.UseBinary = true;
            ftp.Method = WebRequestMethods.Ftp.UploadFile;
            HttpPostedFile file = Request.Files[0]; //you can use inputid.PostedFile too 
            Stream str = file.InputStream;
            byte[] buffer = new byte[file.ContentLength];
            str.Read(buffer, 0, file.ContentLength);
            Stream ftpstream = ftp.GetRequestStream();
            ftpstream.Write(buffer, 0, buffer.Length);
            ftpstream.Close();
            lblMessage.Visible = false;
            lblMessage.Text = "Your file has been uploaded successfully.";
        }
        catch (Exception ex)
        {
            lblMessage.Visible = false;
            lblMessage.Text = ex.ToString();
        }
How i will upload the large size file through ftp. Please suggest me.

 

Posted on Jan 14, 2014 11:31 PM

The hosting company replied that big files upload is not possible via scripts on shared hosting environment. I am using the shared server.So, uploading the large size video file is not possible in my case. Thanks to all for your support.

I agree, here is the link: https://www.e-iceblue.com/Introduce/spire-office-for-net-free.html