Post file content : File Upload : CGI Web PYTHON TUTORIALS


PYTHON TUTORIALS » CGI Web » File Upload »

 

Post file content


import cgi
form = cgi.FieldStorage()
if not form:
    print "Content-Type: text/htmlnn"
    print """
    <form action = "/uploadingfile.py" method="POST" enctype="multipart/form-data">
    <input type="file" name="filename">
    <input type="submit">
    </form>
    """
elif form.has_key("filename"):
    uploadedfile = form["filename"]
    if uploadedfile.file:
        print "Content-Type: text/htmlnn"
        linecounter = 0
        while 1:
            line = uploadedfile.file.readline()
            print line
            if not line:
                break
            linecounter = linecounter + 1



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo CGI Web
» File Upload