title: Upload a file with python using httplib
body: <pre><code>conn = httplib.HTTPConnection("www.encodable.com/uploaddemo/")
  conn.request("POST", path, chunk, headers)
  </code></pre>
  
  <p>Above is the site "www.encodable.com/uploaddemo/" where I want to upload an image. </p>
  
  <p>I am better versed in <code>php</code> so I am unable to understand the meaning of path and headers here. In the code above, <code>chunk</code> is an object consisting of my image file. 
  The following code produces an error as I was trying to implement without any knowledge of headers and path.</p>
  
  <pre><code>import httplib
  
  def upload_image_to_url():
  
      filename = '//home//harshit//Desktop//h1.jpg'
      f = open(filename, "rb")
      chunk = f.read()
      f.close()
  
      headers = {
          "Content−type": "application/octet−stream",
          "Accept": "text/plain"
      }
  
      conn = httplib.HTTPConnection("www.encodable.com/uploaddemo/")
      conn.request("POST", "/uploaddemo/files/", chunk)
  
      response = conn.getresponse()
      remote_file = response.read()
      conn.close()
      print remote_file
  
  upload_image_to_url()
  </code></pre>