- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 libcurl 将“.txt”文件从 Ubuntu Linux 上传到 apache http 服务器。
我在Linux系统中编写了以下c代码来执行http post上传到我的服务器
#include <stdio.h>
#include <curl/curl.h>
#include <sys/stat.h>
int main(void)
{
CURL *curl;
CURLcode res;
FILE *fd;
struct stat file_info;
fd = fopen("/home/shantanu/test.txt", "rb"); /* open file to upload */
if(!fd)
return 1; /* can't continue */
/* In windows, this will init the winsock stuff */
/* to get the file size */
if(fstat(fileno(fd), &file_info) != 0)
return 1; /* can't continue */
curl_global_init(CURL_GLOBAL_ALL);
/* get a curl handle */
curl = curl_easy_init();
if(curl) {
/* First set the URL that is about to receive our POST. This URL can
just as well be a https:// URL if that is what should receive the
data. */
curl_easy_setopt(curl, CURLOPT_URL, "http://x.x.x.x/dashboard/");
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE,(curl_off_t)file_info.st_size);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
/* Now specify the POST data */
curl_easy_setopt(curl, CURLOPT_POSTFIELDS,fd);
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
/* Check for errors */
if(res != CURLE_OK)
fprintf(stderr, "curl_easy_perform() failed: %s\n",
curl_easy_strerror(res));
/* always cleanup */
curl_easy_cleanup(curl);
}
curl_global_cleanup();
return 0;
}
================================================在服务器端的仪表板文件夹中,我有一个名为 index.php 的文件,该文件具有以下代码以将文件移动到该位置
<?PHP
move_uploaded_file($_FILE['content']['tmp_name'], "test.txt");
?>
================================================== =================
但是文件没有上传,我得到以下o/p
* Trying 1x.6x.32.157...
* Connected to 1x.6x.32.157 (1x.6x.32.157) port 80 (#0)
> POST /dashboard/ HTTP/1.1
Host: 1x.6x.32.157
Accept: */*
Content-Length: 2487
Content-Type: application/x-www-form-urlencoded
Expect: 100-continue
< HTTP/1.1 100 Continue
* We are completely uploaded and fine
< HTTP/1.1 200 OK
< Date: Fri, 11 May 2018 10:32:20 GMT
< Server: Apache/2.4.33 (Win32) OpenSSL/1.1.0g PHP/7.2.4
< X-Powered-By: PHP/7.2.4
< Content-Length: 117
< Content-Type: text/html; charset=UTF-8
<
<br />
<b>Notice</b>: Undefined index: content in <b>C:\xampp\htdocs\dashboard\index.php</b> on line <b>2</b><br />
最佳答案
CURLOPT_POSTFIELDS想要一个 char *
,你要向它传递一个 FILE *
关于c - 无法使用 libcurl 将 .txt 文件从 ubuntu linux 上传到 apache http 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50290856/
我构建了 nss 的 64 位版本,并尝试使用它来使用 --without-ssl 和 --with-nss=NSS_ROOT 选项构建curl 库。 在配置阶段,我看到以下内容: checking
我访问了 4 页。每个页面设置cookies。我如何向 libcurl 询问所有 cookie 或特定 cookie(如“session_id”)的值? 最佳答案 curl_easy_getinfo
我正在使用 libcurl 开发一个 c 程序。 当我构建我的程序时,我可以使用不同版本的 libcurl。 当我从版本更改为其他(libcurl)时,我必须更改源代码中的一些 block 以使其适应
我需要使用“Content-Type: application/json”进行 HTTP DELETE 调用。我如何使用 libcurl 接口(interface)来做到这一点。 最佳答案 我认为在
我通常是一名 Java 开发人员,但我现在正在编写一个 C++ 库,他们将使用 LibCurl。而且我对 C++ 世界一无所知! 我正在写的实际上是供其他开发人员使用的库(它是用于访问我们的 API
我刚刚注意到当我使用 IP 进行 HTTPS 调用时,libcurl 没有设置 SNI 字段。我发现了这个: https://github.com/curl/curl/blame/master/lib
我正在开发 Linux 嵌入式应用程序,它充当客户端并使用 libCurl 从 https 服务器接收数据。我的应用程序的要求是接受过期的证书并继续建立连接。 我找不到任何可以使用 curl_easy
我正在尝试在 OS X 10.11(目标 10.8)上构建启用 SSL 的静态 libcurl.a: export MACOSX_DEPLOYMENT_TARGET="10.8" ./configur
我正在尝试执行rake db:create命令。我收到以下错误 无法打开库'libcurl':libcurl:无法打开共享对象文件:无此类文件或目录。 Could not open library '
我之前问过一个关于 libcurl 的问题。我已经设法自己找到了答案,并且很乐意分享我是如何解决这个问题的,只要我确定它有效。事情是这样的,在此之前,当我尝试编译时链接器会出错,经过一些搜索和反复试验
我已经使用以下配置标志成功地在系统和非 root 用户上安装了 libcurl: ./configure --prefix=/path/to/lib --exec-prefix=/path/to/li
我一直在尝试通过将 libcurl.a 添加到我的 Xcode 7.2 项目来消除对 libcurl.4.dylib 的任何依赖。我构建了一个全新的 libcurl 并将其放在/usr/local/l
我试图在 CentOS6 上安装 R 3.3.2。但不知何故我无法使 libcurl 支持 https。 Here有人建议安装 libcurl:libcurl-devel (rpm) 或 libcur
我试图 curl 到我的本地主机 laravel 站点。我正在使用 XAMPP 7.1 当我尝试重新连接此代码时,总是会出现错误(而不是 200 OK 响应) Fatal error: Uncaugh
在我的开发过程中,我的代码运行正常。当我推送到我的服务器时,它变成了错误。 cURL 错误 6:无法解析主机:http(请参阅 http://curl.haxx.se/libcurl/c/libcur
GuzzleHttp\Exception\RequestException cURL 错误 60:SSL 证书问题:无法获取本地颁发者证书(请参阅 https://curl.haxx.se/libcu
我遇到了这个错误 cURL error 3: malformed (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)将多个模型保存/创建到
如何强制libcurl通过ipv4或ipv6访问以双堆栈模式运行的服务器?使用IP地址应该不难,但是我正在寻找可以与DNS配合使用的东西... 最佳答案 你打赌可以将config CURLOPT_IP
我正在使用 libcurl 从 url 下载文件。文件的原始大小是 1700k,但我只得到 1200k。在我用数据包嗅探器检查后,我意识到数据是以分块编码和 gzip 格式传入的。此外,我的进度回调始
我正在为我的一个项目使用 libcurl。我知道 curl 不用于发出多个并发请求,但 libcurl 是否支持它? 我知道还有其他工具,例如 ab,但 libcurl 提供了很多功能。我再次知道我可
我是一名优秀的程序员,十分优秀!