In your code, you're not actually inserting the contents of the file into
your MIME part (you're only constructing headers), which is why the
content-length is not right.

The 404 is probably the site detecting this as a script/robot/violation of
their TOS and blocking you.  Which you can probably get around by modifying
your user-agent string, but as a security guy I suppose you can figure that
out.

If you understand that there are better libraries but refuse to use them,
you might try at least looking at how they implement this.


On Mon, May 6, 2013 at 12:05 PM, Ajin Abraham <aji...@gmail.com> wrote:

> Hi,
>    I was working on a python project that requires to upload an image
> using httplib. Here i need to POST a MULTI PART DATA with Python using
> inbuilt libraries. I know there are better libraries like requests and
> poster. but i need to do it with httplib itself.
>
> I will attach a screenshot==> http://s1.postimg.org/qjjhy445q/file.jpg
>
> So here i think there is some problem with my code that the
> 'Content-Length is different and i am getting a 404 not found
> response. i placed the file "screenshot.png" together with my python
> source file.
>
> Here is my source code==>http://bpaste.net/show/V2xbtcBSpYsNbwGPCmFM/
>
> Please tell me what's wrong in my code. and please don't suggest me
> other libraries.
>
> Regards,
> Ajin Abraham
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to