我正在使用 Jquery FineUploader 上传我得到的文件
404 - 找不到文件或目录。
当为小于 30MB 的小文件上传大于 30MB 的文件时,工作正常。
在火灾错误中,错误显示:
[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")
下面是我的处理程序代码:
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));
}
}