1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-11-03 08:07:17 -05:00
elinks/test/cgi/big_file.cgi

30 lines
536 B
Plaintext
Raw Normal View History

#!/usr/bin/env python
HAS_HASHLIB = False
try:
import hashlib
HAS_HASHLIB = True
except:
import md5
import cgi
2008-05-03 06:08:54 -04:00
print "Content-Type: text/plain\r\n"
form = cgi.FieldStorage()
if form.has_key("file"):
plik = form["file"]
length = 0
if plik.file:
if HAS_HASHLIB:
dig = hashlib.md5()
else:
dig = md5.new()
while 1:
data = plik.file.read(1000000)
if not data:
break
length += len(data)
dig.update(data)
2008-05-03 06:08:54 -04:00
print "Filename = " + plik.filename
print "Size = %d" % length
2008-05-03 06:08:54 -04:00
print "MD5 = " + dig.hexdigest()