|
-
UPLOAD_COMPLETE_DATA - return size limit?
I'm doing an image upload that returns a large chunk of data - I'm base64-encoding the uploaded image and returning it immediately within an XML document. This data is retrieved via the UPLOAD_COMPLETE_DATA handler.
On my Windows machine, the data comes back perfectly. On my Mac, however, only a small piece is returned. If the file that I upload is more than a few kilobytes in size, only a truncated version of the data is returned (exactly 2,634 bytes each time). This leads me to believe that there is a limit (at least on the Mac version of the Flash player) to the amount of data that can be returned this way. Anyone else experienced this issue?
And yes, I've tested the backend thoroughly, the entire image is being uploaded correctly - I can save it to the server, I've even created text files of the output on the server just to make sure the right info is being sent back.
I've completely simplified my code for testing. There are two buttons (browse and upload) and a textarea to view the output.
PHP Code:
var fr:FileReference = new FileReference();
browse_btn.addEventListener(MouseEvent.CLICK,doBrowse);
upload_btn.addEventListener(MouseEvent.CLICK,doUpload);
function doBrowse(e:Event):void{ fr.browse(); }
function doUpload(e:Event):void
{
var URLreq:URLRequest = new URLRequest("scriptnamehere.php");
fr.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA,uploadSuccess);
fr.upload(URLreq);
}
function uploadSuccess(e:DataEvent):void{
debug_textarea.text += e.data;
}
Any feedback would be appreciated.
-
What's tracing out from e.data?
Are you listening to other events on that FileReference like ioErrors or httpStatus? It sounds more like you're getting some sort of error or something on the mac side.
-
neznein9,
Yes, I'm listening to ioErrors, httpErrors, and securityErrors (I left them out of my code above for simplicity). I'm getting no errors. I wish I were, then I'd have something to work towards.
The PHP code that I'm calling is this:
PHP Code:
//open uploaded file
$fd = fopen ($_FILES['Filedata']['tmp_name'], 'rb');
$size=filesize ($_FILES['Filedata']['tmp_name']);
$cont = fread ($fd, $size);
fclose ($fd);
//base64 encode uploaded file
$encimg = base64_encode($cont);
header("Content-type:text/xml");
echo "<response action=\"upload\"><status>1</status><responsedata><image>";
echo $encimg;
echo "</image></responsedata></response>";
On the Windows side, e.data returns the full XML string:
Code:
<response action="upload">
<status>1</status>
<responsedata>
<image>#@$@#$@#$@#$ (lots of base64-encoded goodness)</image>
</responsedata>
</response>
on the Mac side I just get a truncated version:
Code:
<response action="upload">
<status>1</status>
<responsedata>
<image>#@$@#$@#$...
It's always the same amount of characters - 2,634. Driving me nuts.
Thanks for looking.
-
Hrmm...can you crack open firebug to see the the data getting sent back and forth? That would at least narrow it down to bad data or the flash player eating something in translation...
Sorry, I'm afraid I'm not much help with specifics here :\
-
Firebug's not being too helpful...the actual upload request/response doesn't show up in Firebug. I looked at some other as3 uploaders online, and had the same results.
-
http response cut on upload_complete_data / air
Dear all,
I can fully confirm your problem: I'm also doing a file upload using file.upload(urlrequest), and catch the server response via the upload_complete_data event.
My response is a relatively big (>1.5kb) XML response, which occasionally just ends being returned.
I then catched the network traffic using wireshark, which clearly showed that the response itself is sent by the server and received on the client completely, but the event.data property of the upload_complete_data event just didn't get it (or, well, partly).
What makes it more strange is that this does only happen occasionally. Even when uploading the same file twice, it may be that it works the first time, but fails on the second time (or vice versa).
For me this really seems as a flash/air problem, and yes, I'm also using the mac version.
so if anyone has an idea what this could be (beside a bug ;-) ), please let us know.
thanks
alex
-
Hi all,
i can confirm the same issue on Mac... Did anybody find a workaround or something similar ? Thanks.
-
Hello,
Maybe puttiong it in CDATA tags would help.
lee
-
mmm... ? anyway i solved this issue getting back response from web server in asyncronous mode.
1- client make POST to webserver
2- web server create an xml file with (huge) response : fileresp.xml
3- web server make a resp to client POST with fileresp.xml url
4- client download fileresp.xml using url in the webserver response
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|