truly working multipart uploads.
timr at probo.com
Tue Nov 11 09:20:46 CET 2003
Hunter Peress <hfastjava at yahoo.com> wrote:
>I have been unable to write a script that can do (and receieve) a multipart form upload.
>Also, it seems that there really are differences between python's implementation and else's.
>Can someone please prove me wrong with a script that works with itself AND with example 18-2
>from php: http://www.php.net/manual/en/features.file-upload.php
Plop this script into a CGI directory somewhere, load it into your browser
and do the upload. Use a text file; it echos the file back out to your
browser. This uses the exact form from the php.net web page.
q = cgi.FieldStorage()
if not q.has_key('userfile'):
<form enctype="multipart/form-data" action="x.py" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="30000">
Send this file: <input name="userfile" type="file">
<input type="submit" value="Send File">
f1 = q['userfile'].filename
contents = q['userfile'].file.read()
contents = q['userfile'].value
print "Content-Type: text/plain"
print "Filename = ", f1
print "Here's the content:"
- Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the Python-list