#!/usr/bin/env python
import cgi,os,sys,cgitb
cgitb.enable()
try:
import msvcrt
msvcrt.setmode(0,os.O_BINARY);
msvcrt.setmode(1,os.O_BINARY);
except ImportError:
pass
print "Content-type:text/html \n\n"
print "<b>Lepy Uploader</b><br/>"
print """
<form enctype = 'multipart/form-data' method = 'post' action = '#'>
File: <input type = 'file' name = 'filer'/><br/>
<input type = 'submit' value = 'Upload'/>
</form>
"""
form = cgi.FieldStorage()
if form.has_key("filer"):
file = form['filer']
if file.filename:
print "URL: <a href = 'http://173.51.231.145/images/"+file.filename+"'>http://173.51.231.145/images/"+file.filename+"</a>"
fn = os.path.basename(file.filename)
open('../images/'+fn,'wb').write(file.file.read())