0
我想上传文本文件到Rails服务器上的红宝石。我成功地通过CLI上传文件:C LibCurl文件上传到Rails服务器上的红宝石
curl -X POST --data-urlencode [email protected]/etc/filepath/ www.example.com/path
现在,通过下与libcurl的尝试:
FILE *fd;
fd = fopen(file_path, "rb");
if (!fd)
return -1;
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
curl_easy_setopt(curl, CURLOPT_POST, 1L);
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
curl_easy_setopt(curl, CURLOPT_READDATA, fd);
}
任何想法,为什么通过命令行会的工作运行,但libcurl的没有?我错过了一些卷曲选项还是我的服务器需要替代配置?
感谢