Phpcurl batch upload with other forms of post. Why can't I upload multiple files to another post?

Source: Internet
Author: User
Phpcurl batch uploads with other forms of post. A single upload can be combined with post. If it can be batch uploaded, it won't work. Is there any way? How can the final running result of {code...} be like a form with $ _ FILES and $ _ POST? A single file is acceptable, but there are many... php curl batch upload with other forms of post. A single upload can be combined with post. If it can be batch uploaded, it won't work. Is there any way?


  'Foo', 'file' => $ file); // Why can't I upload multiple files? // convert to/$ data = $ file; curl_setopt ($ ch, CURLOPT_URL, 'HTTP: // localhost/upload. php '); curl_setopt ($ ch, CURLOPT_POST, 1); if (class_exists (' \ CURLFile ') {curl_setopt ($ ch, CURLOPT_SAFE_UPLOAD, true );} else {if (defined ('curlopt _ SAFE_UPLOAD ') {curl_setopt ($ ch, CURLOPT_SAFE_UPLOAD, false); // 5.6 is set to true, get back} curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ data); curl_e Xec ($ ch); // close the cURL resource and release the system resource curl_close ($ ch);?>

How can the final running result be like a form?$_FILESYouyou$_POSTWhat about it?

A single file is acceptable, but multiple files cannot. What should I do?

Reply content:

Php curl batch upload with other forms of post. A single upload can be combined with post. If it can be batch uploaded, it won't work. Is there any way?


  'Foo', 'file' => $ file); // Why can't I upload multiple files? // convert to/$ data = $ file; curl_setopt ($ ch, CURLOPT_URL, 'HTTP: // localhost/upload. php '); curl_setopt ($ ch, CURLOPT_POST, 1); if (class_exists (' \ CURLFile ') {curl_setopt ($ ch, CURLOPT_SAFE_UPLOAD, true );} else {if (defined ('curlopt _ SAFE_UPLOAD ') {curl_setopt ($ ch, CURLOPT_SAFE_UPLOAD, false); // 5.6 is set to true, get back} curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ data); curl_e Xec ($ ch); // close the cURL resource and release the system resource curl_close ($ ch);?>

How can the final running result be like a form?$_FILESYouyou$_POSTWhat about it?

A single file is acceptable, but multiple files cannot. What should I do?

I remember to give a file name. The array cannot be passed. Only keys can be specified.

$ Postfileds = ['file1' => CURLFile (xxxxx 'file2' => CURLFile (xxxxxxx # Be sure to use an array, then write 'file [] '=> CURLFile (xxxxxx 'File [] '=> CURLFile (xxxxx];

Set file_path to an array for loop execution

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.