Curl: The Receiving address of the uploaded file $ _ FILES is empty.

Source: Internet
Author: User
Code sent (completely official example) {code ...} receive code (also official) {code ...} running result {code ...} I was going to post php. ini configuration, but the upload location is not found. Let's take a look at the configurations that I need to post as soon as possible. Curl_setopt ($ ch, CURLO... code sent (completely official example)


   'Foo', 'file' => '@/home/vagrant/test.png');curl_setopt($ch, CURLOPT_URL, 'http://localhost/test/curl/load_file.php');curl_setopt($ch, CURLOPT_POST, 1);curl_setopt($ch, CURLOPT_POSTFIELDS, $data);curl_exec($ch);?>

Receive code (also official)


  

Running result

php -f demo.php Array( [name] => Foo [file] => @/home/vagrant/test.png)Array()

I was prepared to paste the php. ini configuration, but I couldn't find the upload location. Let's take a look at the configurations that I need to post as soon as possible.
Curl_setopt ($ ch, CURLOPT_VERBOSE, TRUE.

Reply content:

Code sent (completely official example)


    'Foo', 'file' => '@/home/vagrant/test.png');curl_setopt($ch, CURLOPT_URL, 'http://localhost/test/curl/load_file.php');curl_setopt($ch, CURLOPT_POST, 1);curl_setopt($ch, CURLOPT_POSTFIELDS, $data);curl_exec($ch);?>

Receive code (also official)


   

Running result

php -f demo.php Array( [name] => Foo [file] => @/home/vagrant/test.png)Array()

I was prepared to paste the php. ini configuration, but I couldn't find the upload location. Let's take a look at the configurations that I need to post as soon as possible.
Curl_setopt ($ ch, CURLOPT_VERBOSE, TRUE.

$ Ch = curl_init (); $ data = array ('name' => 'foo', 'file' => '@/home/vagrant/test.png '); curl_setopt ($ ch, CURLOPT_URL, 'HTTP: // localhost/test/curl/load_file.php '); curl_setopt ($ ch, CURLOPT_POST, 1); curl_setopt ($ ch, CURLOPT_SAFE_UPLOAD, false); // if the value 5.6 is set to true, get back to curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ data); curl_exec ($ ch);?>

Found in sf: Consider PHP 5.0 ~ 5.6 cross-version compatibility cURL File Upload

It looks good.

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.