I have been using the AJAXUploader with the TempFileLocation set in the tag, but today, I started setting the TempFileLocation in my page_load event from an appSetting in the webconfig. Now, when the form is submitted, the TempFileName property of the AJAXPostedFile class in the AJAXUploader is coming up null. I watched the upload create the three files (.status, .info, .data), but when the form is submitted, the .data file is deleted and the property becomes null.
Here is my implemtation:
Code: HTML/ASPX
<eo:AJAXUploader
ID="AJAXUploader1"
runat="server"
Width="250px"
AllowedExtension=".flv|.mov|.avi|.wmv|.mpeg|.mp4|.mpeg4|.jpg"
AutoUpload="false"
ClientSideOnError="invalidFileExtension">
</eo:AJAXUploader>
Code: C#
// Set Uploader properties
private void SetUploaderProperties()
{
AJAXUploader1.TempFileLocation = ConfigurationManager.AppSettings["UploaderTempLocation"];
AJAXUploader1.FinalFileLocation = ConfigurationManager.AppSettings["UploaderFinalFileLocation"];
}
// and the postback method to save the video uploaded:
protected void ui_btn_SaveVideo_Click(object sender, EventArgs e)
{
foreach (EO.Web.AJAXPostedFile file in AJAXUploader1.PostedFiles)
{
//Get the temp file name
string tempFileName = file.TempFileName;
//Create the final file name based on the original file name
finalFileName = System.IO.Path.Combine(AJAXUploader1.FinalFileLocation + @"\", file.ClientFileName);
//Move the file to the desired location
if (System.IO.File.Exists(finalFileName))
{
System.IO.File.Delete(finalFileName);
}
System.IO.File.Move(tempFileName, finalFileName);
break; // Just grab the first one if the user uploaded more files.
}
}
This was working before I started setting the Uploader.TempFileLocation and FinalFileLocation from my page_load method, now, the .data file is deleted and the TempFileName ends up null so the .Move method fails.
Why would setting those properties in code cause the .data file be deleted?
Thanks,
Duane