|
Rank: Newbie Groups: Member
Joined: 9/17/2007 Posts: 9
|
I've set up a small website with an AJAXUploader and I load that into an iframe on another site. What I'm trying to do is give myself the option to have a callback so that the parent page can be notified when the upload is complete so that I can update my display of uploaded files. I'm trying to use the ClientSideOnProgress and getPercentage to determine when the file is done uploading.
The problem is that I'm looking for getPercentage() == 100, but I get 3 to 5 ClientSideOnProgress events where it is 100. Sometimes I get one where it says the value of getPercentage() is "Infinity".
Can I reliably check for "Infinity" or is there something else I can trap?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
Don't rely on that, getPercentage is a rounded value, so if the total is 1000 bytes and 999 bytes have been done, you will get round(99.9) = 100.
You can either rely on AutoPostBack to inform you that the upload has been done; or rely on the second and the third parameter of ClientSideOnProgress handler, which gives you the total number of bytes and total number of transfered bytes respectively. If you see both number greater than zero and have the same value, that means the upload is done.
Thanks
|
|
Rank: Newbie Groups: Member
Joined: 9/17/2007 Posts: 9
|
How would I use the AutoPostback? I've actually got AutoPostback set to true for my uploader (user only uploads one file at a time). Does that affect the technique?
Thanks!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
Well, if you use AutoPostBack then you don't need to use ClientSideOnProgress to catch whether the upload has completed. When AutoPostBack is set to true, the uploader will trigger server side event FileUploaded immediately when the upload is done. Inside there you can perform any operation just like you handle a Button_Click event.
Thanks
|
|
Rank: Newbie Groups: Member
Joined: 9/17/2007 Posts: 9
|
Your first solution to use the total vs received bytes solved the issue of the event firing off twice, but it caused another problem. When total = received, the file name turns to null. I'm trying to save file meta data (file name, size, etc) to a database. The database code is being run in my main web application on one server and the file upload is being done on another server (throug the iframe). I need to pass data from my iframe back to my main page. I don't know of an easy way to pass the data from a server side event handler to the parent page, so I was trying to do it through javascript (have a callback style javascript function in the parent aspx and check in the iframe's aspx if it exists, and if it does, call it). The method worked, but I can't seem to get all the data I need.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
That's fairly easy. Just use a global variable to remember the last file name you see before you see total = received.
Thanks
|
|
Rank: Newbie Groups: Member
Joined: 9/17/2007 Posts: 9
|
I thought of doing that.
PS - The developer support here is some of the best I've seen. Great job guys!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
OneMHz wrote:I thought of doing that.
PS - The developer support here is some of the best I've seen. Great job guys! Good to hear that. Please spread the word. :)
|
|