tags:

views:

31

answers:

1

I can;t figure out how to do this. Someone selects and image after calling FileReference.browse(). I take that image and make a thumbnail in flash.

Then I upload that image like so:

var newFileReq:URLRequest = new URLRequest(FILE_UPLOAD_TEMP);
newFileReq.contentType = "application/octet-stream";

var fileReqVars:URLVariables = new URLVariables();
fileReqVars.image = myThumbImage;
fileReqVars.folder = "Thumbs";
newFileReq.data = fileReqVars;
newFileReq.method = URLRequestMethod.POST;


//upload the first image
fileRef.addEventListener(Event.COMPLETE, onFirstFileUp);
fileRef.upload(newFileReq, "Filedata");

All this does it upload the original image. How do I change the fileRef to upload the new thumb? I have traced out the size of the "myThumbImage" and it is correct. I have placed it visually on the stage after creating the thumb, and it seems like it works. But when I upload it to an aspx page (that basically just throws it into a folder), it uploads the original larger image.

A: 

It won't work this way. FileReference.upload can only upload the file you opened, you can not override the image for security reasons.

What you should do to achieve this is encode the thumbnail data properly using Base64 (and use something like as3corelib to encode it to jpeg or png first if your thumb is just a bare bitmap data), and then use URLLoader to post the thumb to the server.