Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Korakot Chaovavanich http://korakot.stumbleupon.com

« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS 

Upload file with http client (multipart/form-data)

   1  
   2  def post_multipart(host, selector, fields, files):
   3      """
   4      Post fields and files to an http host as multipart/form-data.
   5      fields is a sequence of (name, value) elements for regular form fields.
   6      files is a sequence of (name, filename, value) elements for data to be uploaded as files
   7      Return the server's response page.
   8      """

See the rest of the implementation here

Send a file using FTP

   1  
   2  import ftplib
   3  s = ftplib.FTP('myserver.com','login','password') # Connect
   4  
   5  f = open('todo.txt','rb')                # file to send
   6  s.storbinary('STOR todo.txt', f)         # Send the file
   7  
   8  f.close()                                # Close file and FTP
   9  s.quit()

Taken (with some mod.) from here
« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS