2

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!

J. Schwind
  • 21
  • 1
  • 4
  • 1
    and the error you got is? – mitkosoft Feb 06 '20 at 15:41
  • I doubt this is related to your PHP upgrade but [here is a link to changes related to CURL](https://www.php.net/manual/en/migration74.incompatible.php#migration74.incompatible.curl) from PHP's migration guide – Andrew Feb 06 '20 at 16:14
  • 1
    **[You should not switch off `CURLOPT_SSL_VERIFYHOST` or `CURLOPT_SSL_VERIFYPEER`](https://paragonie.com/blog/2017/10/certainty-automated-cacert-pem-management-for-php-software)**. It could be a security risk! [Here is how to get the certificate bundle if your server is missing one](https://stackoverflow.com/a/32095378/1839439) – Dharman Feb 08 '20 at 17:46

1 Answers1

0

It looks like an issue with the setting in php.ini file in the updated PHP7.4 version, Please check if you have extension=php_curl.dll added with in [ExtensionList] section.

Bineesh John
  • 128
  • 6