Python - CGI script

Andreas Jung ajung at sz-sb.de
Thu Dec 30 04:59:57 EST 1999


On Thu, Dec 30, 1999 at 04:01:27AM +0000, Luis Cortes wrote:
> Hello,
> 
> 	I am trying to figure out how to make a HTML page that will allow me 
> to "upload" files to the server from the Client system.  If anyone out 
> there has some code I sure would appreciate it.
> 
> Thanks,
> Luis.
> 


*snip*

<form action="/cgi-bin/upload.py" enctype="multipart/form-data" method=post>
<input type=file name="userfile">
.....
</form>


upload.py:


import cgi

form = cgi.FieldStorage()

fileitem = form['userfile']

if fileitem.file:

    fname = tempfile.mktemp()
    fp=open(fname,'w')
    fp.write(fileitem.file.read())
    fp.close()

.....

-- 
                                _\\|//_
                               (' O-O ')
------------------------------ooO-(_)-Ooo--------------------------------------
   Andreas Jung, Saarbrücker Zeitung Verlag und Druckerei GmbH
   Saarbrücker Daten-Innovations-Center
   Untertürkheimerstraße 15, D-66103 Saarbrücken, Germany
   Phone: +49-(0)681-502-1528, Fax: +49-(0)681-502-1509
   Email: ajung at sz-sb.de (PGP key available)
-------------------------------------------------------------------------------
"Well is UNIX Y2K-compliant?" and I said, ``No problem at all, but in 2038 I
plan on being retired, because it is not going to be a good year for UNIX
systems!'' (GvR)




More information about the Python-list mailing list