views:

186

answers:

1

There seems to be so many ways of uploading images to a PHP enabled server, it is difficult to make sense of the various options and under what circumstances it is prefereable to use one over the other. On the front end you have the option to JPGencode or not, use a ByteArray or not, further compress the ByteArray or not. On the server side, assuming one is using PHP, there is the option of whether to use third party remoting (ZendAMF or AMFphp) or not and what the pros cons of each are.

What I see as the core sequence of steps on the front end, regardless of options

  1. A Bitmapdata object is created representing the image that is to be uploaded-saved to the server.
  2. If using JPG encoding the BitMapdata is encoded, if not skip and proceed to step 3.

  3. If using a ByteArray, a new byteArray object is instantiated and made equal to either 1 or 2, if not skip and proceed to step 4.

  4. Connect to service -upload-save image data

Can anyone correct and or elaborate on the above?

A: 

i think, the most simple and natural way is to take the ByteArray or BitmapData (which is completely interchangable using getPixels and setPixels), encode it to JPG or PNG using as3corelib and then send it ... the advantages of encoding on client side are

  1. obviously, bandwidth
  2. your data becomes a real file and is not just binary data ... you can store it to the file system directly and server it through http ... a BitmapData is just a 32-bits-per-pixel chunk, not even storing the image size ... use PNG if you want it lossless, JPG otherwise ...

most simple thing to me, would be to send it up to the server using standard URLLoader class ... data is simply in the $HTTP_RAW_POST_DATA ... there is no reason to use a framework here, unless the rest of your server is based on one of the mentioned frameworks ...

hope that helps ...

back2dos