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. css3动画如何解决动画的播放、暂停和重新开始

    0921自我总结 css3如何解决动画的播放.暂停和重新开始 一.解决的本质思路 播放的解决思路 先定义好动画效果通过类名的增加达到样式的出现 暂停的解决思路 我们播放动画时,如要暂停动画,就要用到a ...

  2. url编码本质

    url编码本质 其实url本质就是将中文字符串进行utf8编码,然后得到编码后的对象转换字符串去掉开头的b'以及末尾的',然后再将\x转换成%,再将里面内容x变成e最后将字符串小写变成大写 举例 #拿 ...

  3. JVM发生full gc的情景有哪些

    除直接调用System.gc外,触发Full GC执行的情况有如下四种.1. 旧生代空间不足 旧生代空间只有在新生代对象转入及创建为大对象.大数组时才会出现不足的现象,当执行Full GC后空间仍然不 ...

  4. 四步解决linux上sublime无法输入中文的问题

    转载请标明博客的地址 本人博客和github账号,如果对你有帮助请在本人github项目AioSocket上点个star,激励作者对社区贡献 个人博客:https://www.cnblogs.com/ ...

  5. JQuery iframe宽高度自适应浏览器窗口大小的解决方法

    iframe宽高度自适应浏览器窗口大小的解决方法   by:授客 QQ:1033553122 1.   测试环境 JQuery-3.2.1.min.js 下载地址: https://gitee.com ...

  6. JS基础语法---arguments对象伪数组

    引入: //计算两个数字的和 function f1(x, y) { return x + y; } //计算三个数字的和 function f2(x, y, z) { return x + y + ...

  7. none 和 host 网络的适用场景

    我们会首先学习 Docker 提供的几种原生网络,以及如何创建自定义网络.然后探讨容器之间如何通信,以及容器与外界如何交互. Docker 网络从覆盖范围可分为单个 host 上的容器网络和跨多个 h ...

  8. Linux-3.14.12内存管理笔记【构建内存管理框架(5)】

    前面已经分析了内存管理框架的构建实现过程,有部分内容未完全呈现出来,这里主要做个补充. 如下图,这是前面已经看到过的linux物理内存管理框架的层次关系. 现着重分析一下各个管理结构体的成员功能作用. ...

  9. vue预览本地图片

    <template> <div> <a href="javascript:void(0);" @change="addImage" ...

  10. Codeforces Round #588 (Div. 2)

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