CGI upload

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Thomas Williams

    CGI upload

    Can anyone tell me where to find info, on writing a
    script that handles a file from a CGI form?

    Thanks in advance.

    Tom Williams

  • Irmen de Jong

    #2
    Re: CGI upload

    Thomas Williams wrote:[color=blue]
    > Can anyone tell me where to find info, on writing a
    > script that handles a file from a CGI form?[/color]

    It's in the manual, about the cgi module:

    The official home of the Python Programming Language


    at the end of the page.

    --Irmen

    Comment

    • Georgy Pruss

      #3
      Re: CGI upload

      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="multip art/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.FieldS torage()
      if form.has_key("f ilename"):
      filedata=form.g etvalue("filena me", "")
      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(fil edata)
      fstrm.close()



      "Irmen de Jong" <irmen@-NOSPAM-REMOVETHIS-xs4all.nl> wrote in message news:3f85b849$0 $58705$e4fe514c @news.xs4all.nl ...[color=blue]
      > Thomas Williams wrote:[color=green]
      > > Can anyone tell me where to find info, on writing a
      > > script that handles a file from a CGI form?[/color]
      >
      > 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
      >[/color]


      Comment

      Working...