Image Uploading Script in Python

3.7k Views Asked by At

I was trying to make an image uploading script for Postimage.org. I tried searching for an API but it seems that there is not any available. Can anyone help me how to make this script ? I don't have any idea how to make the uploading proccess? I think that something that i should do is open the image file in read binary mode ("rb"). Anyway i am waiting for your suggestions and ideas.

1

There are 1 best solutions below

2
On

Firstly you should think about what happens when you press the upload button on the website. What your script could do is mimic this functionality, because essentially all it's triggering is a POST request to the web server with the specified information in the form and the image file data. You can initiate HTTP requests (e.g. GET, POST, etc.) using a library such as Requests (http://docs.python-requests.org/en/latest/index.html).

However, as this seems to have been discussed before, I will instead point you in the right direction: Send file using POST from a Python script