View comments | RSS feed

onHTTPError (FileReference.onHTTPError event listener)

onHTTPError = function(fileRef:FileReference, httpError:Number) {}

Invoked when an upload fails because of an HTTP error.

Because of the way that Flash Player relies on the browser stack during file download, this error is not applicable for download failures. If a download fails because of an HTTP error, the error is reported as an I/O error.

Availability: ActionScript 1.0; Flash Player 8

Parameters

fileRef:flash.net.FileReference - The File Reference object that initiated the operation.

httpError:Number - The HTTP error that caused this upload to fail. For example, an httpError of 404 indicates that a page is not found. HTTP error values can be found in sections 10.4 and 10.5 of the HTTP specification at ftp://ftp.isi.edu/in-notes/rfc2616.txt.

Example

The following example creates a FileReference object with a listener for each possible event including onHttpError. This listener is triggered only if the upload fails because of an HTTP error.

import flash.net.FileReference;

var listener:Object = new Object();

listener.onSelect = function(file:FileReference):Void {
    trace("onSelect: " + file.name);
    if(!file.upload("http://www.yourdomain.com/yourUploadHandlerScript.cfm")) {
        trace("Upload dialog failed to open.");
    }
}

listener.onCancel = function(file:FileReference):Void {
    trace("onCancel");
}

listener.onOpen = function(file:FileReference):Void {
    trace("onOpen: " + file.name);
}

listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void {
    trace("onProgress with bytesLoaded: " + bytesLoaded + " bytesTotal: " + bytesTotal);
}

listener.onComplete = function(file:FileReference):Void {
    trace("onComplete: " + file.name);
}

listener.onHTTPError = function(file:FileReference):Void {
    trace("onHTTPError: " + file.name);
}

listener.onIOError = function(file:FileReference):Void {
    trace("onIOError: " + file.name);
}

listener.onSecurityError = function(file:FileReference, errorString:String):Void {
    trace("onSecurityError: " + file.name + " errorString: " + errorString);
}

var fileRef:FileReference = new FileReference();
fileRef.addListener(listener);
fileRef.browse();


Version 8

Comments


Chuck Deisler said on Sep 19, 2005 at 3:24 PM :
Ok.. that's all good but how do you get to this file on the server side in .NET?
dr. feelgood said on Dec 6, 2005 at 6:27 AM :
Flash Player 8 on OSX 10.4 (tested with Safari) will throw an error (HTTP error 404) when posting to a server-side script running on a subdomain, such as http://myapp.mydomain.com/.

This behaviour occurred on Mediatemple, I cant speak for other environments. It also works on XP.

http://myapp.mydomain.com/doUpload.php --> doesnt work
http://www.mydomain.com/myapp.mydomain.com/doUpload.php --> works

Took us a while to hunt this one down :-)

mk
No screen name said on Jan 24, 2006 at 4:41 AM :
on one of my clients severs i'm getting an "onHTTPError" 404 after the "onProgress" reaches 100%.
how is this possible?
Shinkaze said on Apr 13, 2006 at 4:36 PM :
This is great and all, but how do I find out *WHICH* FTTP error the file recieved? (404, etc?). For testing purposes we're getting a ton of errors, but it's not telling us why and we don't know how to find out why......anyone know?
R3DD4G said on May 17, 2006 at 3:49 PM :
Any http errors such as 403, 406 or where a file upload goes to a 100% but doesn't show up on the server is a result of the mod_security. Mod_sercurity blocks the post request of flash because it is missing a ":". To correct this problem create or find the .htaccess file in your root directory then type in:

SecFilterEngine Off
SecFilterScanPOST Off

that should correct your problem.
No screen name said on Oct 4, 2006 at 2:42 PM :
also, you may try this in your php.ini file if you are having problems with uploading large files:

; Maximum allowed size for uploaded files.
upload_max_filesize = 50M

; Maximum size of POST data that PHP will accept.
post_max_size = 50M
HC00JW said on Jan 15, 2007 at 5:51 AM :
In response to dr. feelgood's comments, this does not work on a Mac with
any of the browsers I have tested in (Safari, Firefox, Opera, Internet
Explorer, etc.), while it does work in all browsers on a PC (Internet Explorer,
Firefox, Opera, etc.), which leads me to believe that this is a problem with
the Flash plugin on a Mac.

Has anyone found an actual solution to getting this to work with
subdomains, or do we (as I suspect) have to wait for a fix from Adobe?
porbista said on Jan 26, 2007 at 6:59 AM :
hi i tried adding both lines to my .htaccess file. But all it did was crash my website. Any other suggestions? Tnx in advance guys :)
stevensanborn said on Feb 9, 2007 at 6:20 PM :
yes i too had the near 100% then http error. This was fixed by

SecFilterEngine Off
SecFilterScanPOST Off

thanks
sophie119 said on Mar 2, 2007 at 5:30 AM :
Hi, I am having troubles with a 405 error sent back to the Player. I can't find
any info about this porblem, but maybe the System.security.loadPolicyFile()
could help? How would I do that?
Thanks greatfully to the one who will help me...
eddy_ said on Mar 6, 2007 at 10:26 AM :
After doing the Mod_sercurity trick width the .htaccess file in the rootdir I got a HTTP Error 500 instead of the HTTP Error 403... So what now? (my fileupload works fine on my testserver - so I know it coded well - but refuses to work on the liveserver)
stephen2earth said on May 9, 2007 at 1:50 AM :
i have a similar problem where it will not work for some reason, it was working on a different server, but when it was transferred i am getting a http error 406, any suggestions would be helpful. Thanks!
wraevn said on May 14, 2007 at 9:26 AM :
I just found this little gem on Ultrashock (thanks Nutrox!)

How do you find out WHAT HTTP error?

listener.onHTTPError = function(file:FileReference, httpError:Number):Void
{
trace("ERR: " + httpError);
}
stephen2earth said on May 15, 2007 at 3:59 AM :
For those still experiencing errors with the FileBrowser Class.
I was having a 406 error on the server,but it was working on a test server.
I managed to discover the reason was in the security of the page,
here is a link to a blog about the problem http://protoflash.com/blog/2007/05/15/filebrowserclass/
flairman said on Jun 20, 2007 at 9:46 PM :
i also have 500 error
the upload file(asp) is correct
what is the problem?
stephen2earth said on Jun 26, 2007 at 1:43 PM :
<a href="http://protoflash.com/blog/2007/05/15/filebrowserclass/">someone else was having a similar problem here<a/>

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/8/main/00002216.html