Advertisement
Guest User

Untitled

a guest
Feb 25th, 2012
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.83 KB | None | 0 0
  1. #!/usr/bin/env python
  2. import cgi,os,sys,cgitb
  3. cgitb.enable()
  4. try:
  5.         import msvcrt
  6.         msvcrt.setmode(0,os.O_BINARY);
  7.         msvcrt.setmode(1,os.O_BINARY);
  8. except ImportError:
  9.         pass
  10.  
  11.  
  12.  
  13. print "Content-type:text/html \n\n"
  14. print "<b>Lepy Uploader</b><br/>"
  15. print """
  16. <form enctype = 'multipart/form-data' method = 'post' action = '#'>
  17. File: <input type = 'file' name = 'filer'/><br/>
  18. <input type = 'submit' value = 'Upload'/>
  19. </form>
  20.  
  21. """
  22. form = cgi.FieldStorage()
  23. if form.has_key("filer"):
  24.         file = form['filer']
  25.         if file.filename:
  26.                 print "URL: <a href = 'http://173.51.231.145/images/"+file.filename+"'>http://173.51.231.145/images/"+file.filename+"</a>"
  27.                 fn = os.path.basename(file.filename)
  28.                 open('../images/'+fn,'wb').write(file.file.read())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement