I am trying to send binary data to a server side script which takes a
variable called file, and saves it as a binary file.
so if I have a variable in my flash movie myfile, with a value of
asdf, and I send that to the server, it will make a file on the
filesystem called myfile, and the contents of it will be asdf
Now, the trick is to send the script an image or video file. I have
tried the following ways:
1) Using FileReference class (Flash 8)
--- This works with php and move_uploaded_file.
--- This does NOT work the server side script mentioned above. It
adds headers to the file. Same headers found here:
http://livedocs.adobe.com/flash/8/main/wwhelp/wwhimpl/common/html/
wwhelp.htm?context=LiveDocs_Partsfile=2225.html
Namely:
Content-Type: multipart/form-data; boundary=AaB03x
--AaB03x
Content-Disposition: form-data; name=Filedata; filename=example.jpg
Content-Type: application/octet-stream
... contents of example.jpg ...
--AaB03x--
PHP can handle this, the other script cannot. Unfortunately we are
stuck with the other script. So I looked at different ways to send
binary data to the server, without using FileReference.
2) Flex Builder 2.
Here we have some new classes. Such as URLRequest and URLLoader,
where you can use URLLoaderDataFormat.BINARY. This transferred the
file to the server side script we are stuck with perfectly. No errors
or problems.
Unfortunately they want a Flash Player 8 solution.
3) Some examples on the web where people have taken a BitmapData
object in Flash 8 and programmatically convert a bitmap into an array
of string data which represents pixel data, which is converted on the
server to an image.
-- Is this method possible with LoadVars to send a binary stream of
data to a script via POST, which will make it think it's the same as
a file upload???
Well these are my three options
1) FileReference -- Flash 8 -- Is there a way to eliminate the
headers its sending by default?
2) Flex Builder 2 - URLLoader class -- Any way to use this in Flash
Player 8? (Doesn't seem possible)
3) Manually encode binary data into a variable and pass it through
loadVars making the server think it's a file upload. Possible???
OR
4) Any other possibility I may have overlooked?
Thanks for any help,
-Carlos-
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com