简体   繁体   中英

CURL with CURLFile works fine with PHP7.3 but not with PHP7.4

here is an example that works fine with php7.3, but not with php7.4.

curl.php

$file='test.txt';
$cfile=curl_file_create($file, mime_content_type($file), 'test.txt');

$post=array('file'=>$cfile);

$ch=curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_SAFE_UPLOAD, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_URL, 'https://example.com/curl-upload.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$response=curl_exec($ch);
print_r(curl_getinfo($ch));
print_r($response);
if (curl_errno($ch)) {
    var_dump(curl_errno($ch));
}

curl-upload.php

echo 'upload';

print_r($_FILES);

$file=file_get_contents('php://input');
print_r($file);

any idea why?

thank you very much!

PHP7.4 版本更新后的 php.ini 文件中的设置似乎有问题,请检查您是否在[ExtensionList]部分添加了extension=php_curl.dll

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM