在用curl_setopt($curl, CURLOPT_POSTFIELDS, $fileData);这个函数设置时会报错如下

curl_setopt(): The usage of the @filename API for file uploading is deprecated. Please use the CURLFile class instead

查看了相关文档发现如下一段话

 

curl_setopt用此函数设置上传文件请求的兼容性调整

curl_setopt用此函数设置上传文件请求的兼容性调整

根据这个提示

得把老版本中的请求参数如

$fileData = ['media' => "@" . $filepath]; 这种写法改成

$fileData = ['media' => new \CURLFile($filepath)];

参考文档:
http://php.net/manual/zh/function.curl-setopt.php
http://stackoverflow.com/questions/18482236/fb-api-php-curl-setopt-array-the-usage-of-the-filename-api-for-file-uploadin

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-25
  • 2022-12-23
  • 2021-04-29
  • 2021-06-05
猜你喜欢
  • 2021-11-26
  • 2022-12-23
  • 2022-12-23
  • 2021-07-21
  • 2022-12-23
  • 2021-12-20
  • 2021-08-17
相关资源
相似解决方案