Upload file using python simply using HTTPLIB
<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. Now problem which I am facing is I am tyro in php so I am unbale to understand the meaning of path and headers in above code, chunk is an object that consist of my image file. 
Following code ofcourse produces error as I was trying to implement without any knowledge of headers and path</p>

<pre><code>import httplib
</code></pre>

<p>def upload_image_to_url():</p>

<pre><code>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
</code></pre>

<p>upload_image_to_url()</p>
