I have the following control markup and codebehind for an instance of the AjaxUploader. On my local dev machine this works fine, but when deployed to our staging server, uploading multiple files at the same time results in an issue where some of the files will upload correctly, but others will fail with the error:
Server side exception : failed to upload Desert.jpg
Debug Information:
System.Exception: File not exists!
at CuteWebUI.UploadModule.a(HttpContext A_0, Guid A_1)
For example, two files out of an upload of 8 may fail with this error, while the other 6 seem to work fine. Is there anything I can do to troubleshoot/resolve the issue?
Markup:
<%@ Register TagPrefix="CuteWebUI" Namespace="CuteWebUI" Assembly="CuteWebUI.AjaxUploader" %>
<CuteWebUI:Uploader id="Uploader1" runat="server" MultipleFilesUpload="true"
AutoUseSystemTempFolder="true" OnUploadCompleted="Uploader_OnUploadCompleted"></CuteWebUI:Uploader>
<script type="text/javascript">
function CuteWebUI_AjaxUploader_OnError(msg)
{
DisplayValidationError($('#validationErrors'), msg);
return false;
}
function CuteWebUI_AjaxUploader_OnTaskError(obj, msg, reason)
{
DisplayValidationError($('#validationErrors'), 'Error uploading ' + obj.FileName + ': ' + msg);
return false;
}
</script>
Code:
protected void Uploader_OnUploadCompleted(object sender, UploaderEventArgs[] e)
{
List<NewUploadedDocument> uploadedDocuments = new List<NewUploadedDocument>();
for (int i = 0; i < e.Length; ++i)
{
var uploadedFile = e[i];
byte[] fileBytes = new byte[uploadedFile.FileSize];
using (var stream = uploadedFile.OpenStream())
{
stream.Read(fileBytes, 0, uploadedFile.FileSize);
}
// Code here to copy the file to a database row
}
// Clean up after the uploads
foreach (var uploadedFile in e)
{
uploadedFile.Delete();
}
}