No one wants to answer !!!
Michal Wallace
sabren at manifestation.com
Sun Aug 27 10:40:07 EDT 2000
On Sun, 27 Aug 2000, Sindh wrote:
> fs=cgi.FieldStorage()
> if fs.has_key("file1"):
> fname=fs["file1"]
> if fname.file:
> data=fname.file.read()
> print len(data)
> else:
> blah blah ...
>
> It works fine for text mode files but dies whan I try with binary or
> image files. Even trying the script with python -u didnot work.
Try fname.file.value, instead of fname.file.read()... As the docs
say:
> If a field represents an uploaded file, the value attribute reads
> the entire file in memory as a string.
Also, are you sure you're setting enctype="multipart/form-data" in
your form tag?
Cheers,
- Michal
------------------------------------------------------------------------
www.manifestation.com www.sabren.com www.linkwatcher.com www.zike.net
------------------------------------------------------------------------
More information about the Python-list
mailing list