#!/usr/bin/env python
import cgitb
cgitb.enable()
import cgi, os, urllib, md5
print "Content-type: text/html"
print
print """
CGI File Example """
form = cgi.FieldStorage()
if form.has_key('file'):
fileitem = form['file']
if not fileitem.file:
print "Error: not a file upload."
else:
print "Got file: %s
" % cgi.escape(fileitem.filename)
m = md5.new()
size = 0
while 1:
data = fileitem.file.read(4096)
if not len(data):
break
size += len(data)
m.update(data)
print "Received file of %d bytes. MD5sum is %s
" % \
(size, m.hexdigest())
else:
print "No file found.
"
print """
"""