cURL / Mailing Lists / curl-library / Single Mail

curl-library

uploading HTTP PUT

From: Danny Guindi <danny.guindi_at_nnu.com>
Date: Mon, 1 Jul 2002 08:50:54 -0500

Hello all,

I have been learning and using libcurl for a couple weeks now, however I have not been able to figure out if the following is possible.

I have a web server (apache) running CGI scripts on a linux box, and I want to upload a file from my personal PC (running Win 2000) to a temporary directory on the linux machine. I am trying to write a CGI script that will promt for a filename and will then upload that file to the temporary directory. This is part of my code,

hd = open("C:\\test.txt", O_RDONLY);
fstat(hd, &file_info);
close(hd);

hd_src = fopen("C:\\test.txt", "rb");
if (!hd_src)
{
    fcgi.Out() << "Error : " << errno << "<BR>" << endl;
    return false;
}

curl = curl_easy_init();

if (curl)
{
    curl_easy_setopt(curl, CURLOPT_READFUNCTION, ReadCallback);
    curl_easy_setopt(curl, CURLOPT_UPLOAD, TRUE) ;
    curl_easy_setopt(curl, CURLOPT_PUT, TRUE);
    curl_easy_setopt(curl, CURLOPT_USERPWD, user_passwd);
    curl_easy_setopt(curl, CURLOPT_URL, dest_url);
    curl_easy_setopt(curl, CURLOPT_INFILE, hd_src);
    curl_easy_setopt(curl, CURLOPT_INFILESIZE, file_info.st_size);

    res = curl_easy_perform(curl);
    curl_easy_cleanup(curl);
}

fclose(hd_src);

It prints out an error indicating that the file to open does not exist!
Can anyone help me?
Thanks,

Danny

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Received on 2002-07-01