Home > Backend Development > PHP Tutorial > CURL上传失败

CURL上传失败

WBOY
Release: 2016-06-13 13:41:29
Original
1047 people have browsed it

CURL上传失败,求助
我使用例子上的代码上传文件,程序不出错,但是tomcat文件夹中没有我上传的文件,请问各位这是何解。
以下是我的代码
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 上传是模拟浏览器的表单上传


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template