CGI upload

Georgy Pruss SEE_AT_THE_END at hotmail.com
Thu Oct 9 18:40:48 EDT 2003


It uploads only a part of the file. Is it a feature of Windows implementation?

<!-- The form-->
<FORM METHOD="POST" ACTION="/cgi-bin/test.py" enctype="multipart/form-data">
<INPUT TYPE=FILE NAME="filename" size=40>
<INPUT TYPE="SUBMIT" VALUE="Upload">
</FORM>


# test.py

print "Content type: text/html"
print

import cgi

form=cgi.FieldStorage()
if form.has_key("filename"):
    filedata=form.getvalue("filename", "")
    assert filedata == form["filename"].value # the same

    print len(filedata), '<br>'  # some 400..800 bytes depending on file :-(

    fstrm = open("test.bin", 'wb')
    fstrm.write(filedata)
    fstrm.close()



"Irmen de Jong" <irmen at -NOSPAM-REMOVETHIS-xs4all.nl> wrote in message news:3f85b849$0$58705$e4fe514c at news.xs4all.nl...
> Thomas Williams wrote:
> > Can anyone tell me where to find info, on writing a
> > script that handles a file from a CGI form?
>
> It's in the manual, about the cgi module:
>
> http://www.python.org/doc/current/lib/node403.html
>
> at the end of the page.
>
> --Irmen
>






More information about the Python-list mailing list