cURL
Haxx ad
libcurl

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-library Mailing List Archives

Re: libcurl c++

From: Uday <nudayasankar_at_gmail.com>
Date: Mon, 26 Mar 2007 14:01:50 +0530

Uploading using HTTP. when I tried PUT/UPLOAD first, I received 405 error.
then only I came to know that our server supports only GET and POST methods.
So, can we upload a file using HTTP_POST?

here's my current attempt.

        curl_easy_setopt(m_handle, CURLOPT_VERBOSE , 1);
        curl_easy_setopt(m_handle, CURLOPT_SSL_VERIFYPEER,0);
        curl_easy_setopt(m_handle, CURLOPT_SSL_VERIFYHOST, 1);
        curl_easy_setopt(m_handle, CURLOPT_TIMEOUT,
m_iRequestTimeout/1000);
        curl_easy_setopt(m_handle, CURLOPT_FOLLOWLOCATION, 1);

        curl_easy_setopt(m_handle, CURLOPT_READFUNCTION, read_callback);
        curl_easy_setopt(m_handle, CURLOPT_POST, 1);
        curl_easy_setopt(m_handle, CURLOPT_READDATA, hd_src);
        curl_easy_setopt(m_handle, CURLOPT_POSTFIELDSIZE,
(curl_off_t)file_info.st_size);
        curl_easy_setopt(m_handle, CURLOPT_URL, m_strEncodedURL.c_str() );

        performResult = curl_easy_perform(m_handle);

On 3/26/07, Daniel Stenberg <daniel_at_haxx.se> wrote:
>
> On Mon, 26 Mar 2007, Uday wrote:
>
> > can anybody help me uploading a file (text/zip) to a remote server
> > using libcurl libraries in c++.
>
> Upload how? What protocol for example?
>
> > when i searched in google, i found that i've to use CURLOPT_POST,
> > CURLOPT_INFILE which points to the actual file & READFUNCTION which
> reads
> > the content from the file and puts in the buffer.
>
> That works for regular HTTP POST, yes, but that's rarely what people
> actually
> mean when they talk about "file upload".
>
> > i'm setting the file size also in CURLOPT_INFILESIZE. i'm not getting
> any
> > exception neither the expected result.
>
> So what is the server expecting you to do? How does your current attempt
> look
> like?
>
> --
> Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
>

-- 
Thanks & Regards,
Uday
Received on 2007-03-26

These mail archives are generated by hypermail.

donate! Page updated November 12, 2010.
web site info

File upload with ASP.NET