Failed to upload CURL. please help me to use the code in the example to upload files. The program will not go wrong, but there will be no uploaded files in the tomcat folder. what is the solution. The following is my code staticsize_tread_callback (void * ptr, size_tsize, size_tnmemb, void * stream) {size_tretcodefread (ptr, si CURL Upload failed, for help
I use the code in the example to upload files. there is no program error, but there is no file I uploaded in the tomcat folder. What is this.
Below is 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;
}
========================================================== ========================================================== =====
In the main () function
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"); // The address is a number on my computer and may be misspelled.
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 ();
========================================================== ========================================================== ==========
In vs2008, every step of debug is taken, but there is no file I uploaded on tomcat, which is 8 kB. Help
Some people say that tomcat has a directory permission problem. I need to modify the internet guest write permission, but I am using the XP system. where is this permission.
In addition, this is my code in cocos2dx, because no one answered the question in c ++, so here I would like to ask, I think the upload part should be the same.
------ Solution --------------------
POST request parameter string (or array)
Curl upload is a form Upload simulation browser.