cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: help, PUT/File upload

From: Bob Schader <rschader_at_product-des.com>
Date: Fri, 02 Feb 2001 06:56:12 -0500

This looks very close to what I have working, but I am PUTting
to an Web-DAV enables Apache server, so my destination URL
is the actual location of the file. The web server directory
to accept these uploads needs to be configured to accept PUT's
also. Are you sure your upload.pl script handles PUT's, most
I have seen only handle POSTS. I would also check your server logs
for errors, etc. If your libcurl is static, you probably don't
need to set the readfunction either. The only other thing I can
see right now that I had trouble with, which I saw in the main.c
of curl, was to change
        infile = fopen("c:\\test.zip", "rb");
to
        infile = (FILE *)fopen("c:\\test.zip", "rb");
Not really sure why that worked, but like I said, it was in the
existing code that way.

Bob Schader

pit_at_paradise.net.nz wrote:
>
> Hi this is my code to upload a file, c:\test.zip to my webserver.
>
> win32_init() and win32_cleanup() are copied from the second sample.
>
> The problem is 'res' gets error 23, every time.
>
> Am i missing some option setting?
>
> Please help.
>
> I'm using BCB5 std.
>
> void __fastcall TForm1::dowork(){
> CURL *curl;
> CURLcode res;
> FILE *infile;
>
> win32_init();
>
> curl = curl_easy_init();
>
> if(curl) {
> curl_easy_setopt(curl, CURLOPT_URL, "http://www.niche.f2s.com/cgi-
> bin/upload.pl");
>
> curl_easy_setopt(curl, CURLOPT_USERPWD, "niche:niche");
>
> curl_easy_setopt(curl, CURLOPT_PUT, 1);
>
> curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_data);
>
> infile = fopen("c:\\test.zip", "rb");
>
> struct stat fileinfo;
> stat("c:\\test.zip", &fileinfo);
> int infilesize = fileinfo.st_size;
>
> curl_easy_setopt(curl, CURLOPT_INFILE, infile);
> curl_easy_setopt(curl, CURLOPT_INFILESIZE, infilesize);
>
> res = curl_easy_perform(curl);
>
> if (res == 0) {
> ShowMessage("GOOD");
> } else {
> ShowMessage(res);
> }
> curl_easy_cleanup(curl);
> }
>
> win32_cleanup();
>
> fclose(infile);
>
> return;
> }
>
> _______________________________________________
> Curl-library mailing list
> Curl-library_at_lists.sourceforge.net
> http://lists.sourceforge.net/lists/listinfo/curl-library

_______________________________________________
Curl-library mailing list
Curl-library_at_lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/curl-library
Received on 2001-02-02