Failed to upload CURL

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.