CURL上傳失敗

來源:互聯網
上載者:User
CURL上傳失敗,求助
我使用例子上的代碼上傳檔案,程式不出錯,但是tomcat檔案夾中沒有我上傳的檔案,請問各位這是何解。
以下是My Code
static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream)
{
size_t retcode = fread(ptr, size,nmemb, (FILE *)stream);

return retcode;
}

=====================================================================================

main()函數中的
CURL *curl;
CURLcode res;
FILE * hd_src ;
int hd ;
struct stat file_info;

hd = open(LOCAL_FILE, O_RDONLY) ;
fstat(hd, &file_info);
close(hd) ;

hd_src = fopen(LOCAL_FILE, "rb");//LOCAL_FILE->d:\\t.txt

curl_global_init(CURL_GLOBAL_ALL);

curl = curl_easy_init();
if(curl) {

curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);

curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);

curl_easy_setopt(curl, CURLOPT_PUT, 1L);

curl_easy_setopt(curl, CURLOPT_URL, "http://localhost:8080/mp3/2.txt");//地址我在自己的電腦是數字,這邊可能有拼字錯誤

curl_easy_setopt(curl, CURLOPT_READDATA, hd_src);

curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE,
(curl_off_t)file_info.st_size);

res = curl_easy_perform(curl);

curl_easy_cleanup(curl);
}
fclose(hd_src);

curl_global_cleanup();

========================================================================================

vs2008上面debug調試每一步都走了,但是伺服器tomcat上面沒有我上傳的檔案,檔案8k。求助呀

有人說是tomcat的目錄許可權問題,需要我修改internet guest寫入許可權,可是我用的是xp系統,這個許可權在什麼地方呢。

另外說下這個是我在cocos2dx中的代碼,因為在c++中提問沒有人回答,所以在這邊請教下,我想上傳部分應該是一樣的。

------解決方案--------------------
POST 方式請求的參數串(或數組)

curl 上傳是類比瀏覽器的表單上傳

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.