cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Uploading a file via HTTP Post

From: Robert Iakobashvili <coroberti_at_gmail.com>
Date: Sun, 1 Jul 2007 15:34:46 +0200

On 7/1/07, Carter R. Harrison <carterharrison_at_mac.com> wrote:
> Emil (and others),
>
> Unfortunately your suggestions didn't work out. Perhaps there's
> another way for me to show what it is that I need. I ran a Wireshark
> capture so that I could capture the exact HTTP traffic that I need to
> mimic with libcurl. Your suggestion got me very close...
>
> What I need the post to look like:
>
> Content-Disposition: form-data; name="upload_file";
> filename="filename.torrent"
> Content-Type: application/octet-stream
> <Binary data follows>
>
> What your suggestion got me:
>
> Content-Disposition: form-data; name="upload_file"
> <Binary data follows>
>
> So clearly I'm missing two things:
> 1. the filename="filename.torrent" part of the form data.
> 2. the content-type for the binary data (this I know how to fix).
>
> So I've been struggling with figuring out how to add this additional
> filename field in using the form_add() function. It doesn't seem to
> provide a way to do this...

Y can add the filename as in the example
http://curl.haxx.se/libcurl/c/curl_formadd.html

> > curl_easy_setopt(mCURL, CURLOPT_POSTFIELDS, post);
This is not correct. Use from the example.
curl_easy_setopt(curl, CURLOPT_HTTPPOST, post);

This can also solve the Content-Type.

Sincerely,
Robert Iakobashvili,
coroberti %x40 gmail %x2e com
...........................................................
http://curl-loader.sourceforge.net
A web testing and traffic generation tool.
Received on 2007-07-01