struct FtpFile {
const char *filename;
FILE *stream;
}; static size_t my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream)
{
struct FtpFile *out = (struct FtpFile *)stream;
if(out && !out->stream) {
/* open file for writing */
out->stream = fopen(out->filename, "wb");
if(!out->stream)
return -1; /* failure, can't open file to write */
}
return fwrite(buffer, size, nmemb, out->stream);
} void fileLoadFtp()
{
CURL *curl;
CURLcode res; QString locale = ui->lineEdit_path->text();
char *file = locale.toLatin1().data();
QFileInfo fileInfo(locale);
QString fileName = fileInfo.fileName();
QString remote = "ftp://user:password@ftp.example.com/" + fileName;
char *remote_url = remote.toLatin1().data(); //服务器路径 struct FtpFile ftpfile = {
file, /* name to store the file as if successful */
NULL
}; curl_global_init(CURL_GLOBAL_DEFAULT); curl = curl_easy_init();
if(curl) {
/*
* You better replace the URL with one that works!
*/
curl_easy_setopt(curl, CURLOPT_URL, remote_url);
/* Define our callback to get called when there's data to be written */
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_fwrite);
/* Set a pointer to our struct to pass to the callback */
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &ftpfile); curl_easy_setopt(curl, CURLOPT_SSH_AUTH_TYPES, CURLSSH_AUTH_PASSWORD); /* Switch on full protocol/debug output */
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); res = curl_easy_perform(curl); /* always cleanup */
curl_easy_cleanup(curl); if(CURLE_OK != res) {
/* we failed */
fprintf(stderr, "curl told us %d\n", res);
}
} if(ftpfile.stream)
fclose(ftpfile.stream); /* close the local file */ curl_global_cleanup();
}

curl ftp libcurl 功能使用的更多相关文章

  1. curl tftp libcurl 功能使用

    #include <curl/curl.h> static size_t read_callback(void *ptr, size_t size, size_t nmemb, void ...

  2. curl http libcurl 功能使用

    /* * This example shows a HTTP PUT operation. PUTs a file given as a command * line argument to the ...

  3. curl sftp libcurl 功能使用

    #include <curl/curl.h> #undef DISABLE_SSH_AGENT struct FtpFile { const char *filename; FILE *s ...

  4. everything 提供http和ftp的功能

    1. 早上起床看知乎,发现everything 有http和ftp的功能, 简单看了一下的确很强大.. 就是有点危险.. 功能位置. 2. 最下面有FTP和HTTP 可以进行启用 这是http的 建议 ...

  5. cURL 是一个功能强大的PHP库。

    使用PHP的cURL库可以简单和有效地去抓网页.你只需要运行一个脚本,然后分析一下你所抓取的网页,然后就可以以程序的方式得到你想要的数据了.无论是你想从从一个链接上取部分数据,或是取一个XML文件并把 ...

  6. Windows7上开启ftp服务器功能

    开启ftp服务功能   1 进入“控制面板”->“程序”->"打开或关闭Windows功能",找到“Internet信息服务”选项 2 将“Internet信息服务”选 ...

  7. curl smtp libcurl 邮件功能使用

    /* * For an SMTP example using the multi interface please see smtp-multi.c. */ /* The libcurl option ...

  8. CURL 和LIBCURL C++代码 上传本地文件,好不容易碰到了这种折腾我几天的代码

    解决了什么问题:curl在使用各种方式上传文件到服务器.一般的文件上传是通过html表单进行的,通过CURL可以不经过浏览器,直接在服务器端模拟进行表单提交,完成POST数据.文件上传等功能. 服务器 ...

  9. php curl ftp上传 下载

    下载 //初始化 $ch=curl_init(); //文件的准确路径url curl_setopt($ch,CURLOPT_URL,"ftp://192.168.151.126/wwwro ...

随机推荐

  1. Python爬虫,你是否真的了解它?

    程序员有时候很难和外行人讲明白自己的工作是什么,甚至有些时候,跟同行的人讲清楚“你是干什么的”也很困难.比如我自己,就对Daivd在搞的语义网一头雾水.所以我打算写一篇博客,讲一下“爬虫工程师”的工作 ...

  2. 【重学Git】高级命令篇

    1.分离HEAD.HEAD 总是指向当前分支上最近一次提交记录. 所谓分离HEAD,就是让HEAD直接指向某一条具体的提交记录,而不是默认的通过分支名指向当前分支的最近一条提交记录. 2.相对引用^. ...

  3. apache部分报错解决方法

    AH00558: 进入apache文件夹下的conf文件夹,打开httpd.conf文件,用ctrl+F找到ServerName,如下图 在下面加上一句: ServerName domain_name ...

  4. 为什么AlertDialog要使用Builder来构建呢

    为什么 AlertDialog 使用Builder 模式呢? 首先说句废话,因为 AlertDialog 太过复杂,内部参数太多,然后不使用构建者模式那么 AlertDialog 的构造方法就可能是: ...

  5. Flutter学习笔记(6)--Dart流程控制语句

    如需转载,请注明出处:Flutter学习笔记(5)--Dart流程控制语句 条件语句:if.if...elseif.if...elseif...else ; ) { print('优秀'); } &g ...

  6. 更改 undo_retention 时,Lob retention 不更改 (Doc ID 563470.1)

    Lob retention not changing when undo_retention is changed (Doc ID 563470.1) APPLIES TO: Oracle Datab ...

  7. Python—创建进程的三种方式

    方式一:os.fork() 子进程是从os.fork得到的值,然后赋值开始执行的.即子进程不执行os.fork,从得到的值开始执行. 父进程中fork之前的内容子进程同样会复制,但父子进程空间独立,f ...

  8. [Go] 使用protobuf进行序列化和反序列化

    先定义消息类型 orders.proto syntax = "proto2"; package message; message Orders { required int32 o ...

  9. Codeforces Round #588 (Div. 2)

    传送门 A. Dawid and Bags of Candies 乱搞. Code #include <bits/stdc++.h> #define MP make_pair #defin ...

  10. wbr 标签实现连续英文字符的精准换行你知道吗?

    1.一般情况下的换行: word-break:break-all或者word-wrap:break-word <p>大家<wbr>想要<wbr>实现<wbr& ...