Q: File Upload Problem

tkssato at yahoo.co.jp tkssato at yahoo.co.jp
Thu Jul 27 04:18:36 EDT 2000


I wrote a simple cgi script to upload files by Web browsers.

It works perfect on Linux with Apache1.3.

But on WindowsNT with Apache1.3, it works only for text files

Uploaded image files are truncated.

I don't understand which my Python script or Apache
causes the problem.

If you know anything about it,
Please let me know.

Thanks for reading this article.

T.Sato
CG & Web engineer
tkssato at yahoo.co.jp

-----------------------------

#!/bin/python
import cgi
form = cgi.FieldStorage()
print "Content-Type: text/html";
print

print "<html>"
if not form.has_key("filename"):
    print """
    <form action="/lib/upload2.html" method="POST"
enctype="multipart/form-data">
    <input type="file" name="filename">
    <input type="submit">
    </form>
    """
else:
    item = form["filename"]
    if item.file:
        data = item.file.read()
        print len(data);        # see if data is truncated here
    else:
        print "no file"

print "</html>"




More information about the Python-list mailing list