truly working multipart uploads.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Hunter Peress

    truly working multipart uploads.

    I have been unable to write a script that can do (and receieve) a multipart form upload.

    Also, it seems that there really are differences between python's implementation and else's.

    Can someone please prove me wrong with a script that works with itself AND with example 18-2
    from php: http://www.php.net/manual/en/features.file-upload.php



    _______________ _______________ ____
    Do you Yahoo!?
    Protect your identity with Yahoo! Mail AddressGuard


  • Lee Harr

    #2
    Re: truly working multipart uploads.

    On 2003-11-09, Hunter Peress <hfastjava@yaho o.com> wrote:[color=blue]
    > I have been unable to write a script that can do (and receieve) a multipart form upload.
    >
    > Also, it seems that there really are differences between python's implementation and else's.
    >
    > Can someone please prove me wrong with a script that works with itself AND with example 18-2
    > from php: http://www.php.net/manual/en/features.file-upload.php
    >
    >[/color]

    I have seen some discussions related to this question recently
    on the python web-sig mailing list:


    Comment

    • Andrew Clover

      #3
      Re: truly working multipart uploads.

      Hunter Peress <hfastjava@yaho o.com> wrote:
      [color=blue]
      > Also, it seems that there really are differences between python's
      > implementation and else's.[/color]

      Why do you say that? I know of no problems with receiving file uploads
      fields in either the standard cgi module or my own replacement for it;
      if you are talking about *sending* multipart/form-data requests, what
      software are you using to create them?

      The main 'gotcha' with sending and receiving form-data is that with
      Windows, stdin and stdout are not by default binary streams, so could
      corrupt newline characters if they are in the file, causing parsing
      problems. If you are using Windows, ensure you have binary streams
      (eg. with python -u).

      --
      Andrew Clover
      mailto:and@doxd esk.com

      Comment

      • Cameron Laird

        #4
        Re: truly working multipart uploads.

        In article <mailman.575.10 68337576.702.py thon-list@python.org >,
        Hunter Peress <hfastjava@yaho o.com> wrote:[color=blue]
        >I have been unable to write a script that can do (and receieve) a
        >multipart form upload.[/color]

        Comment

        • Tim Roberts

          #5
          Re: truly working multipart uploads.

          Hunter Peress <hfastjava@yaho o.com> wrote:
          [color=blue]
          >I have been unable to write a script that can do (and receieve) a multipart form upload.
          >
          >Also, it seems that there really are differences between python's implementation and else's.
          >
          >Can someone please prove me wrong with a script that works with itself AND with example 18-2
          >from php: http://www.php.net/manual/en/features.file-upload.php[/color]

          Plop this script into a CGI directory somewhere, load it into your browser
          and do the upload. Use a text file; it echos the file back out to your
          browser. This uses the exact form from the php.net web page.


          #! /usr/local/bin/python

          import os
          import cgi

          q = cgi.FieldStorag e()

          if not q.has_key('user file'):
          print """\
          Content-Type: text/html

          <html><head><ti tle>Testing</title></head>
          <body>
          <form enctype="multip art/form-data" action="x.py" method="POST">
          <input type="hidden" name="MAX_FILE_ SIZE" value="30000">
          Send this file: <input name="userfile" type="file">
          <input type="submit" value="Send File">
          </form>
          </body>
          </html>"""

          else:
          f1 = q['userfile'].filename
          if q['userfile'].file:
          contents = q['userfile'].file.read()
          else:
          contents = q['userfile'].value

          print "Content-Type: text/plain"
          print
          print "Filename = ", f1
          print "Here's the content:"
          print contents

          --
          - Tim Roberts, timr@probo.com
          Providenza & Boekelheide, Inc.

          Comment

          Working...