This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 25th, 2012  |  syntax: Python  |  size: 0.83 KB  |  views: 30  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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())
clone this paste RAW Paste Data