Uploading binary files

Harry Testmeier test at online.com
Thu Jul 6 18:03:25 EDT 2000


On Fri, 30 Jun 2000 16:46:49 GMT, "Chris Biegay"
<cbiegay at objectmentor.com> wrote:

>I'm trying to upload files through an HTML form, but it only works
>for text files.  When I try to send a jpeg or something the process just
>hangs, and I can't even change the script afterward since the webserver
>won't release the file!  Any ideas?  This is basically how I'm doing it now:
>
>form = cgi.FieldStorage()
>formItem = form[inputName]
>
>if formItem.file:
>    print "Received file [" + formItem.filename + "]"
>    data = formItem.file.read()
>    ...

Hi Chris, 

your Python code seems to be OK, but did you specify an "enctype" in
your HTML-code (e. g. 
<form method="post" action="test.html"
enctype="multipart/form-data">)?

Hope this helps

	Arnold



More information about the Python-list mailing list