-4

I am facing a problem when user uploads a file with size more than 50 MB. FTP code is throwing exception "Maximum file size was exceeded".

I have placed code below.

if (ftp.IsConnected)
{
    var destPath = Convert.ToString(Session["fullpath"]);
    int BUFFER_SIZE = file.ContentLength; // 64KB buffer
    byte[] buffer = new byte[file.ContentLength];
    using (Stream readStream = file.InputStream)
    using (Stream writeStream = ftp.OpenWrite(string.Format("{0}/{1}", destPath, file.FileName)))
    {
        while (readStream.Position < readStream.Length)
        {
            buffer.Initialize();
           int bytesRead = readStream.Read(buffer, 0, BUFFER_SIZE);
           writeStream.Write(buffer, 0, bytesRead);
       }
        ViewState["fileContentLenght"] = file.ContentLength;
        writeStream.Flush();

    }
}
halfer
  • 19,824
  • 17
  • 99
  • 186
Varinder
  • 1,780
  • 2
  • 11
  • 18

1 Answers1

0

To diagnose if it's the C# code or if it's the server, open a command prompt and use command line FTP to PUT the same file to the server. If the server errors out and returns a 400 or 500 level error during the PUT, it's a server file size limitation.

If it's determined that it is a server side limitation, you should contact the FTP server admin and see if they can't increase your upload limits on the server.

WebDrive
  • 1,248
  • 12
  • 19