-->

Uploading data with Flex and getting the bytes sen

2019-07-23 16:39发布

问题:

I want to upload data (not a local file) with Flex (4.1), and show what the progress is of the bytes sent.

Now I use a URLLoader, but I know that URLLoader was designed to download data, I can connect a listener to ProgressEvent.PROGRESS but that has no effect.

I also know there is a FileReference object which supports uploading. The problem here is, I do not want to browse for a file and upload it. I have a byte array which I want to send to the server, but the data property of FileReference is read-only.

So my question is: How can I send the byte array (which is actually a PNG encoded image) to the server and be able to track the progress of the bytes sent to server?

回答1:

Yes, you are right that the data property of FileReference is read-only, but you can track the progress.

If you want to use the URLLoader to upload data, you can try the uploadposthelp class.

You may have a look on the following site: http://labs.findsubstance.com/2008/04/03/as3-upload-encode-images/