[Tutor] Tutor digest, Vol 1 #609 - 14 msgs

Sharriff Aina NHYTRO@compuserve.com
Fri, 23 Feb 2001 03:34:13 -0500


Hello Arcege!

should=B4nt the code read:

  #### if form.has_key('name') ###

Instead? =


Regards

Sharriff


Message text written by INTERNET:tutor@python.org
>import cgi
form =3D cgi.FieldStorage()
if form.has_key('file'):  # from <INPUT name=3D"file"...>
    fileitem =3D form['file']
    if fileitem.file:
        contents =3D []
        line =3D fileitem.file.readline()
        while line:
            bytes =3D len(len)
            contents.append( line )
            line =3D fileitem.file.readline()
            if fileitem.length !=3D -1 and fileitem.length !=3D bytes:
                raise ValueError("data read not same as Content-Length")
        # get the client-given filename, the contents and length
        file =3D (fileitem.filename, contents, fileitem.length)<