ydn-javascript - Very strange problem with uploader

Mark E. Haase
2009-07-02T20:57:03+00:00

I got the uploader working on my project in just a few hours on Tuesday.
It's very nice. I did the development on Safari, so my first cross-browser
test was to upload to the integration environment and try it in Firefox 3.
It didn't work.
This has led me down an agonizing path all day Wednesday and Thursday trying
to get to the bottom of this... after painstakingly setting up an action
script compiler and debugger and adding exception handlers and trace
statements, I have finally begun to shed light on the issue.

My setup is based very closely on this YUI example: Advanced Uploader
Example With Additional POST Variables and Server Data
Return<http://developer.yahoo.com/yui/examples/uploader/uploader-advanced-postvars.html>
.

The only difference is that I have embedded it inside a dynamically loaded
YUI panel.

With logging enabled (and an exception handler in the uploader.swf itself),
I added a log message to the actionscript constructor. Then I watched the
trace while I select a file and then try to upload it.

Here's what happens in Safari:

Logging has been turned on.

creating the upload AS object

Multiple file upload has been turned off.

The file list has been cleared.

Mouse rolled over the uploader.

Mouse down on the uploader.

Mouse up on the uploader.

Mouse click detected, launching 'Open File' dialog.

Browsing for a single file.

Mouse clicked on the uploader.

Mouse rolled out the uploader.

The file list has been cleared.

Files Selected:

CIMG0370.JPG




> Started upload for file0

Progress for file0: 690176 / 1539255

Progress for file0: 1419264 / 1539255

Progress for file0: 1539255 / 1539255

Upload complete for file0

Got data back for file0:

{"success":true,"error":""}


This is all good. Now here's what happens in firefox:

Logging has been turned on.

creating the upload ASS object

Multiple file upload has been turned off.

The file list has been cleared.

Mouse rolled over the uploader.

Mouse down on the uploader.

Mouse up on the uploader.

Mouse click detected, launching 'Open File' dialog.

Browsing for a single file.

Mouse clicked on the uploader.

Mouse rolled out the uploader.

The file list has been cleared.

Files Selected:

CIMG0370.JPG



Logging has been turned on.

*creating the upload AS object*

Multiple file upload has been turned off.

The file list has been cleared.

TypeError: Error #1009: Cannot access a property or method of a null object
> reference.

at Uploader/upload()

at Function/http://adobe.com/AS3/2006/builtin::apply()

at flash.external::ExternalInterface$/-callIn()

at <anonymous>()


As you can see, for some reason, in Firefox, the uploader object is
re-created immediately after I select the file. (I bolded that line to make
it clear.) When the upload function is called on the actionscript object,
the file object is now null, and it throws that error as a result.

So this is where I am. I have a huge headache from staring at the screen for
2 days straight. Any ideas whats going on here? Why would the uploader
object get re-created in Firefox and not safari?

ydn-javascript - Re: Very strange problem with uploader by Mark E. Haase on 2009-07-03T14:25:05+00:00
Well, I figured out the issue with this.

I modified the example to hide the progress bar initially, then show it when
the user is ready to upload.

function onFileSelect(event) {
    for (var file in event.fileList) {
        if(YAHOO.lang.hasOwnProperty(event.fileList, file)) {
            fileID = event.fileList[file].id;
        }
    }

    //document.getElementById('selectedFileDisplay').style.display =
"block";
    document.getElementById('progressReport').value = "Ready to upload: " +
event.fileList[fileID].name;
}

See the commented out line? If that's uncommented, then it causes firefox to
reload the flash object when this function is called, which resets the flash
objects internal state and causes it to forget which file it selected.

Not the case in Safari.

Hopefully this helps somebody... I spent 20 or so hours debugging this. FML

On Thu, Jul 2, 2009 at 4:55 PM, Mark E. Haase <mehaase@gmail.com> wrote:

> I got the uploader working on my project in just a few hours on Tuesday.
> It's very nice. I did the development on Safari, so my first cross-browser
> test was to upload to the integration environment and try it in Firefox 3.
> It didn't work.
> This has led me down an agonizing path all day Wednesday and Thursday
> trying to get to the bottom of this... after painstakingly setting up an
> action script compiler and debugger and adding exception handlers and trace
> statements, I have finally begun to shed light on the issue.
>
> My setup is based very closely on this YUI example: Advanced Uploader
> Example With Additional POST Variables and Server Data Return<http://developer.yahoo.com/yui/examples/uploader/uploader-advanced-postvars.html>
> .
>
> The only difference is that I have embedded it inside a dynamically loaded
> YUI panel.
>
> With logging enabled (and an exception handler in the uploader.swf itself),
> I added a log message to the actionscript constructor. Then I watched the
> trace while I select a file and then try to upload it.
>
> Here's what happens in Safari:
>
> Logging has been turned on.
>
> creating the upload AS object
>
> Multiple file upload has been turned off.
>
> The file list has been cleared.
>
> Mouse rolled over the uploader.
>
> Mouse down on the uploader.
>
> Mouse up on the uploader.
>
> Mouse click detected, launching 'Open File' dialog.
>
> Browsing for a single file.
>
> Mouse clicked on the uploader.
>
> Mouse rolled out the uploader.
>
> The file list has been cleared.
>
> Files Selected:
>
> CIMG0370.JPG
>
>
>
>
>> Started upload for file0
>
> Progress for file0: 690176 / 1539255
>
> Progress for file0: 1419264 / 1539255
>
> Progress for file0: 1539255 / 1539255
>
> Upload complete for file0
>
> Got data back for file0:
>
> {"success":true,"error":""}
>
>
> This is all good. Now here's what happens in firefox:
>
> Logging has been turned on.
>
> creating the upload ASS object
>
> Multiple file upload has been turned off.
>
> The file list has been cleared.
>
> Mouse rolled over the uploader.
>
> Mouse down on the uploader.
>
> Mouse up on the uploader.
>
> Mouse click detected, launching 'Open File' dialog.
>
> Browsing for a single file.
>
> Mouse clicked on the uploader.
>
> Mouse rolled out the uploader.
>
> The file list has been cleared.
>
> Files Selected:
>
> CIMG0370.JPG
>
>
>
> Logging has been turned on.
>
> *creating the upload AS object*
>
> Multiple file upload has been turned off.
>
> The file list has been cleared.
>
> TypeError: Error #1009: Cannot access a property or method of a null object
>> reference.
>
>  at Uploader/upload()
>
>  at Function/http://adobe.com/AS3/2006/builtin::apply()<http://adobe.com/AS3/2006/builtin::apply%28%29>
>
>  at flash.external::ExternalInterface$/-callIn()
>
>  at <anonymous>()
>
>
> As you can see, for some reason, in Firefox, the uploader object is
> re-created immediately after I select the file. (I bolded that line to make
> it clear.) When the upload function is called on the actionscript object,
> the file object is now null, and it throws that error as a result.
>
> So this is where I am. I have a huge headache from staring at the screen
> for 2 days straight. Any ideas whats going on here? Why would the uploader
> object get re-created in Firefox and not safari?
>
Loading


$ This page is proudly powered by www.pubbs.net, you can see more at javascript archive | Partners: ListWare Global Manufacturers