首页 > Web开发 > 详细

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

时间:2016-04-18 13:24:29      阅读:716      评论:0      收藏:0      [点我收藏+]

在用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

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

 

技术分享

技术分享

根据这个提示

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

$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

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

原文:http://www.cnblogs.com/ryanlamp/p/5404035.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!