Welcome Guest Search | Active Topics | Sign In | Register

AJAXUploader clientside getPostedFiles not consistently reflecting actual posted files Options
TMcCabe
Posted: Wednesday, October 8, 2014 2:25:43 PM
Rank: Member
Groups: Member

Joined: 12/9/2010
Posts: 28
I am using EO Web 11.0.66.2

I have an AJAXUploader control that I am using to load multiple files (one at a time), and then will commit to my database after applying some additional information in a two stage operation. My AjaxUploader is within an EO:CallbackPanel, and it a trigger for the panel. This in turn is in a user control hosted in a fairly complex page. Since I can't post this, I recognize that the best I can hope for is a hint of where I might be going wrong.

Ultimately, I believe that the Posted File array in the AJAXUploader is being cleared out, which is making it difficult to display the uploaded but not yet processed files to the user without a postback.

I can set the AJAXUploader to auto-postback and read the files out of the posted file list, but I'd rather show the list of posted files entirely client side.

I am seeing this with IE 11, IE 9 and FireFox.

Code: HTML/ASPX
<eo:AJAXUploader ID="AJAXUploader" runat="server" ClientSideOnError="UploaderOnError" FinalFileList="AJAXPostedFileList" FinalFileLocation="~/UploadTemp" Height="168px" Rows="1"   TempFileLocation="~/UploadTemp" Width="400px" SavePostedFileList="False" ClientSideOnChange="uploader_changed">


I have a a Layout Template with a PostedFiles placeholder and -- for testing purposes, a DIV that I am updating with the posted files

Code: JavaScript
function uploader_changed() {
            var uploader = eo_GetObject("AJAXUploader");
            var postedFiles = uploader.getPostedFiles();
            var postedFileHtml;
            var postedFileCount = postedFiles.length;

            postedFileHtml = "Posted Files: " + postedFileCount;
            ;

            for (i = 0; i < postedFileCount; i++)
            {
                var postedFile = postedFiles[i];
                var fileName = postedFile.getClientFileName();
                var fileSize = postedFile.getFileSize();

                postedFileHtml = postedFileHtml + "&lt;br/&gt;" + fileName + "[" + fileSize + "]";
            }

            $("#postedFileList").html(postedFileHtml);

            
}


When I upload a file, the PostedFiles placeholder and the div are both updated as I'd expect with the file. However, as I upload more files, usually, but not necessarially, at the 4th file, the previously loaded files 'vanish' from the placeholder and my div (and the getPostedFoles().length resets. I have seen this happen immediately on posting a second file, and once after posting about 6 files. However, most frequently, it occurs when posting the 4th. I am using the same files in the same order for my tests.

Since the files are actually in the PostedFileList, when I perform my 2nd stage operation, the files are actually there and the 2nd stage includes all of the files uploaded, including the ones not in getPostedFiles.

eo_support
Posted: Thursday, October 9, 2014 3:29:13 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,196
Hi,

Please check whether your page has posted back. The difference between PostedFileList and AJAXUploader in term of the list is PostedFileList keeps the "submitted list", while AJAXUploader only keeps the list that has NOT been submitted yet. Here "submit" means posting back the page and trigger FileUploaded event. Consider the following sequence:

1. User clicks "browse" button to browse a file;
2. If the AJAXUploader's AutoUpload is set to true, or user clicks "Upload" button explicitly, the upload begins;
3. The upload runs until finishes;
4. The AJAXUploader's file list is updated;
5. If the AJAXUploader's AutoPostBack is set to true, or a post back is trigger somehow (for example, user clicks "Save" button to post back the page), then a post back occurs and FileUploaded event is triggered;
6. The PostedFileList is updated;
7. The AJAXUploader's file list is cleared;

Step 1 and step 4 can repeat many times and then proceed to step 5 and step 6 --- you can think "uploading" a file in the AJAXUploader is the same as "type a letter" in a textbox. Just like the TextBox's Text property only change when user submits the page, items only added to PostedFileList when the page updates.

You can also think the client file list is the list of files for which FileUploaded event is to be triggered. As soon as the page posts back (for example, it maybe triggered by the user, or triggered by an unintentionally AJAX call), FileUploaded event is triggered for the list and the list is cleared. This ensures that for each file uploaded, FileUploaded event only triggers once.

Hope this helps you to resolve the issue. Please feel free to let us know if you still have any questions.

Thanks!
TMcCabe
Posted: Monday, October 13, 2014 9:51:54 AM
Rank: Member
Groups: Member

Joined: 12/9/2010
Posts: 28
In my original scenario, I'd been avoiding posting back (although I suppose that it may have been occuring implicitly).

I've changed now to auto-postback, and I'm writing the PostedFileList contents to the screen via a label control. This is working for me (albiet requiring a screen refresh).
eo_support
Posted: Monday, October 13, 2014 9:56:31 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,196
Hi,

Glad that you got it working. Most likely your initial code has implicit postbacks. Post back and screen refresh does not have to go together --- for example, an AJAX callback is is also a postback, but it may or may not refresh screen. So it is possible for you to have auto-postback but does not have full screen refresh (you will need to refresh at least the AJAXUploader though).

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.