|
Rank: Member Groups: Member
Joined: 3/13/2010 Posts: 13
|
Have the AJAXUploader implemented on my site and everything is working fine, EXCEPT: The first upload works fine. If I upload the same file a second time it works fine. If I upload a DIFFERENT file the second time, I get errors in my FileUploaded event. My code errors because it appears that it is trying to process a file that was already processed on the last postback. I thought explicitly calling ClearPostedFiles would do the trick, but it didn't make any difference. Banging head against wall trying to figure out what I'm missing. I do not have the uploader in an update panel or anything like that, however it is in a user control (incorporated declaratively in aspx, not dynamically in code behind). A nudge in the right direction would be greatly appreciated.
Code: HTML/ASPX
<eo:AJAXUploader ID="eoUploader" runat="server" Width="390px"
AutoPostBack="true"
AutoUpload="true"
MaxDataSize="200000"
MaxFileCount="3"
TempFileLocation="c:\inetpub\AJAXUploaderTemp\"
FinalFileLocation="c:\inetpub\AJAXUploaderFinal\"
FinalFileList="eoFileList" />
<eo:AJAXPostedFileList ID="eoFileList" runat="server" />
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
ClearPostedFiles clears the AJAXUploader's PostedFiles collection. It does not change anything regarding AJAXPostedFileList. Please try to change your code to rely on PostedFiles property and see if that works for you.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 3/13/2010 Posts: 13
|
Thanks for the prompt response!
Are you suggesting that I NOT use the built in automatic feature that you provide in your samples that automatically moves the uploaded files from temp location to final location?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
No. That is not what we meant. The line is between AJAXUploader control and AJAXPostedFileList control. What we suggested is to solely rely on AJAXUploader control and ignore AJAXPostedFileList in your code. AJAXUploader will automatically move the uploaded files from temp to final location as long as FinalFileLocation is set, regardless whether FinalFileList is set. Note these are two different properties.
When AJAXUploader moves the file to FinalFileLocation, it will check whether a file with the same name already exists. If one already exists, it will append a number to the new file name (for example, if you upload "test.txt" twice, the first time you will see “test.txt”, the second you will see "test 2.txt" and so on). This occurs regardless whether there is an AJAXPostedFileList control involved or not.
When this happens, if you examine the AJAXPostedFile object's ClientFileName and FinalFileName, you will see the file name portion in these two properties to be different. The ClientFileName will contain the original file name ("test.txt"), where as FinalFileName will contain the full path of your final file name (for example, "your_final_file_dir\test 2.txt"). FinalFileName is the name of the file that is really sitting on your server thus should be what your server side code uses. You server side code should not care about the client side file name.
Hope this helps. Please let us know if this makes any sense to you.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 3/13/2010 Posts: 13
|
Thank you VERY much for the clear and detailed explanation. I was looping through the AJAXPostedFileList.FinalFileList collection instead of the AJAXUploader.PostedFiles collection (which begs the question, what would you want to use the AJAXPostedFileList collection for in code, but I'm sure there is some use for it). I just changed my code from:
Code: Visual Basic.NET
For Each pf As EO.Web.AJAXPostedFile In eoFileList.FinalFileList
to:
Code: Visual Basic.NET
For Each pf As EO.Web.AJAXPostedFile In eoUploader.PostedFiles
Works like a champ now. Thanks for the help!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Yes. That will do it. Glad that it's working for you now!
|
|