[EMAIL PROTECTED] wrote:
I'm trying to save an image from a Flash AS3 to my server as a jpg
file. I found some PHP code to do this, but I want to do this in
Python. I'm not quite sure how to convert the following code to
Python. It's mainly the $GLOBALS["HTTP_RAW_POST_DATA"] part I don't
know how to convert.
depends on what framework you're using. if you're using plain CGI, you
should be able to read the posted data from sys.stdin:
import sys
im = sys.stdin.read()
f = open(name, 'wb')
f.write(jpg)
f.close()
to make your code a bit more robust, you may want to check the
content-length before doing the read, e.g.
import os
if os.environ.get("REQUEST_METHOD") != "POST":
... report invalid request ...
bytes = int(os.environ.get("CONTENT_LENGTH", 0))
if bytes > MAX_REQUEST_SIZE:
... report request too large ...
im = sys.stdin.read(bytes)
to deal with query parameters etc, see
http://docs.python.org/lib/module-cgi.html
</F>
--
http://mail.python.org/mailman/listinfo/python-list