CGI File Upload

Bill Seitz fluxent at yahoo.com
Tue Dec 5 10:18:54 EST 2000


In article <8u7fn7$jpf$1 at la-mail4.digilink.net>,
  "Pete Shinners" <pete at visionart.com> wrote:
> "Simon Faulkner" <news at titanic.co.uk> wrote
> > I would like users to be able to upload .jpeg files via a web page
> > <input type=file>
> >
> > What python code do I need to be able to save the file to a
directory
> > on the hard disk?
>
> i have some code that does this.. you'll probably want to clean
> it to suit your own purposes, but here it is. at some point i
> wanted to add PIL support to resize the images to a certain
> resolution and convert them to be JPG, but that day hasn't come
> yet... heh. note it also allows the user to save a comment as a
> .TXT file. anyways, you can use it as a start for whatever you want

Hmm, this works for me with text data (though the file length is
slightly different: maybe line-end changes from Win to *nix?). With
binary it's totally off. Uploading a JPEG I consistently only get 109
bytes written to the file system. With GIFs I consistently get ~500
bytes (but not always exactly the same number). With an MsWord file I
get a bigger file written, but still not the whole thing (60kb out of
75kb).

What do I do next?


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list