| |
|
|
|
cURL Mailing List Monthly Index Single Mail
curl-library Mailing List Archives
ftp upload results in (nil) filename
From: Tom Sorensen <tsorensen_at_dtrac.com>
Date: Mon, 3 Feb 2003 10:27:13 -0500
I'm trying to use libcurl to upload some files in a C++ program (no
Speaking of which, the current curl_easy_setopt page on the web
Here's a sample C program that replicates the behavior. I'm on AIX 4.3.3
Thanks for any help.
--- begin
----
#include <stdio.h>
#include <stdlib.h>
#include <curl.h>
size_t dataSize;
size_t
readFtpData(void* ptr, size_t size, size_t nmemb, void* stream)
{
size_t total = size * nmemb;
if (total > dataSize)
{
total = dataSize;
}
if (total > 0)
{
memcpy(ptr, stream, total);
memcpy(stream, ((char*)stream)+total, dataSize-total);
dataSize -= total;
}
return total;
}
int
main(int argc, char* argv[])
{
char* destURL = "ftp://yourhosthere/tmp/test/";
char* userpwd = "user:passwd";
char* data =
"asdlfjsdjfksjadkfjsdkjf;jsdkl;jfl;sdghhgadshfohyfpoyiopqypwoe\n";
CURL* myCurl = curl_easy_init();
curl_easy_setopt(myCurl, CURLOPT_VERBOSE, 1);
curl_easy_setopt(myCurl, CURLOPT_NOPROGRESS, 1);
curl_easy_setopt(myCurl, CURLOPT_URL, destURL);
curl_easy_setopt(myCurl, CURLOPT_USERPWD, userpwd);
curl_easy_setopt(myCurl, CURLOPT_INFILESIZE, strlen(data));
curl_easy_setopt(myCurl, CURLOPT_UPLOAD, 1);
curl_easy_setopt(myCurl, CURLOPT_READFUNCTION, readFtpData);
curl_easy_setopt(myCurl, CURLOPT_READDATA, data);
dataSize = strlen(data);
curl_easy_perform(myCurl);
curl_easy_cleanup(myCurl);
return 0;
}
--- end
ftptest.c -----------------------------------------------------------------
----
-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
Received on 2003-02-03
These mail archives are generated by hypermail. |
Page updated November 12, 2010.
web site info