jqueryasp.netfilefile-uploadfine-uploader

Error when attempting to parse xhr response text For Long Size File


I am using the Jquery fineUploader for Upload the file I am getting

404 - File or directory not found.

when uploading the file more than 30MB for Small files below than 30MB works fine.

In fire bug the error shows:

[FineUploader] Error when attempting to parse xhr response text
(SyntaxError: JSON.parse: unexpected character)

 [FineUploader] Caught exception in 'onValidate' callback -TypeError: file is undefined
 log(a="[FineUploader] Caught e...rror: file is undefined", b="error")

enter image description here

below is my handler code:

 public void ProcessRequest(HttpContext context)
{
    string directoryID = context.Request["dId"];
    var response = new AjaxResponse { ResponseData = "" };

    if (!string.IsNullOrEmpty(directoryID))
    {
        int spaceID = 0;
        int dirID = Convert.ToInt32(directoryID);

        string directoryPhysicalPath = "D:\\Files\\";
        string fileName = context.Request["qqfile"];

        string saveLocation = Path.Combine(directoryPhysicalPath, fileUniqueName);
        if (!Directory.Exists(directoryPhysicalPath))
        {
            Directory.CreateDirectory(directoryPhysicalPath);
        }

        DateTime currentDateTime = DateTime.UtcNow;

        var file = new File();
        try
        {
            int bytesRead = 0;
            Stream inputStream = context.Request.InputStream;
            byte[] buffer = new byte[inputStream.Length];

            try
            {
                using (var fileStream = new FileStream(saveLocation, FileMode.Create))
                {
                    do
                    {
                        bytesRead = context.Request.InputStream.Read(buffer, 0, buffer.Length);
                        fileStream.Write(buffer, 0, bytesRead);
                    } while (bytesRead > 0);
                }

                file = new File
                {
                    FileName = fileName
                };

               //Add to DB Here

            }
        }
        catch (PathTooLongException ex)
        {
            response.IsError = true;
            response.ResponseMessage = ex.Message;
        }

        File f = //Get data from DB here;

        response.ResponseData = f;

        context.Response.Write(new JavaScriptSerializer().Serialize(response));

    }
}

Solution

  • Great Thanks, I have solve this issue to put the below settings in web.config under <system.webServer> section

      <security>
        <requestFiltering >
            <requestLimits maxAllowedContentLength="2000000000"/>
        </requestFiltering>
    </security>