TwelvestoneFlash

filereference quirk with XP/FireFox?


Sign in

  • Waiting for Godot ( 720 k posts )
    Just conversation.
  • Thunder Dome ( 23 k posts )
    Photoshop Tennis and Collabs.
  • Photography ( 4.8 k posts )
    For all you shutterbugs, sh...
  • Flash ( 18 k posts )
    ActionScripting to tweens, ...
  • Front End ( 5.8 k posts )
    general front end design an...
  • Back End ( 9.6 k posts )
    serverside scripting, progr...
  • Projects and Theory ( 12 k posts )
    This forum is for discussio...
  • FAQ ( 269 posts )
    All those nagging questions...
  • Design ( 17 k posts )
    graphics & all aspects of g...
  • Purgatory ( 3.6 k posts )
    12stone Jail, feel free to ...
baron ruhstoff
 
2008-06-09

I'm stumped... I have an app in which users can save screenshots. The app draws to a bitmap, uploads the data, the server creates the file, and the user is then prompted to download the file.

It works great in all browser/OS combos with the exception of FF2/XP. The file is uploaded, but the user doesn't receive the download prompt. What gives?

// EDIT: Turns out the security error is thrown at the start of the upload attempt.

baron ruhstoff
 
2008-06-10

Woo-hoo! It's not working in IE7/Vista or FF2/Vista either!

JLM
 
2008-06-10

your saving a jpg to the server, is that were the prob is or somewhere else?

baron ruhstoff
 
2008-06-10

Threw in a debug trace. It looks as though it's a security issue - Error #2170 - that occurs during file upload.

Getting closer, but still stumped.

baron ruhstoff
 
2008-06-10

Here's what I've tried, all of which happen to coincide with where I've failed:

Security.allowDomain(DOMAIN);

^ probably moot given that the image data is uploaded via URLLoader, which doesn't take a LoaderContext as the second param for load() as Loader does.

Enjoy:

    // post to server
    private function postToServer(byteArray:ByteArray){

        // create a random filename
        _strFileName = "littleguy" + Math.floor(Math.random()*1000000) + ".jpg";
        // optional name/value pairs
        var parameters:Object = new Object(); // optional generic object containing name value pairs to accompany the post

        // set up the security handling
        Security.allowDomain(DOMAIN);

        // set up the request & headers for the image upload;
        var urlRequest : URLRequest = new URLRequest();
        urlRequest.url = UPLOADPATH + UPLOADSCRIPT;
        urlRequest.contentType = 'multipart/form-data; boundary=' + UploadPostHelper.getBoundary();
        urlRequest.method = URLRequestMethod.POST;
        urlRequest.data = UploadPostHelper.getPostData( _strFileName, byteArray );
        urlRequest.requestHeaders.push( new URLRequestHeader( 'Cache-Control', 'no-cache' ) );

        // create the image loader & send the image to the server;
        var urlLoader : URLLoader = new URLLoader();
        urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
        urlLoader.addEventListener(Event.COMPLETE, onComplete);
        urlLoader.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
        urlLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError);
        urlLoader.addEventListener(ProgressEvent.PROGRESS, onUploadProgress);
        urlLoader.load( urlRequest);

        }
baron ruhstoff
 
2008-06-10

A little correction for clarification: the data is not being uploaded. The security error is thrown at the start of the upload attempt.

baron ruhstoff
 
2008-06-10

All righty. Moving the php script to the same server as the swf seems to have taken care of the security error... on most machines. The two I was most concerned about - IE6/XP and FF2/XP - are now squared away. It still throws the error on FF2/[some unknown and old version of Mac OS], but hey... it's progress.

JLM
 
2008-06-11

Here's an idea which I untidied prior to posting

_jpgUrlReq=new URLRequest(_sendImagePath+'?id='+id+'&cashKill='+(new Date()).getTime()); _jpgUrlReq.requestHeaders.push(new URLRequestHeader("Content-type","application/octet-stream")); _jpgUrlReq.method=URLRequestMethod.POST;
_jpgUrlReq.data=(new JPGEncoder(COMPRESS)).encode((new BitmapData(_w,_h).draw(_img)); var l:Loader = new Loader(); l.contentLoaderInfo.addEventListener(Event.INIT, onComplete ); l.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,ioError ); l.load(_jpgUrlReq);

the php needs to return a dummy image, as far as I know it works cross browser/platform but is rather dirty in its use of loader.

Sorry, you must be a member to post to a conversation. Either log in or sign up to get involved.
TwelvestoneFlash

filereference quirk with XP/FireFox?