#!/usr/bin/env python #coding: utf8 import cgi print "Content-Type: text/html" # HTML is following print # blank line, end of headers form = cgi.FieldStorage() img = form["img"] imgsz = form["imgsz"] print imgsz if img.file: # It's an uploaded file; count lines rcv = 0 while 1: chunk = img.file.read(1024) if not chunk: break rcv += len(chunk) assert rcv == imgsz