php5.5之后php官方推薦使用CURLFile類來模擬代替之前的@+全文件路徑方式上傳文件
if(class_exists('\CURLFile')) {
//可以使用
$filedata = [
'fieldname' => new \CURLFile ( realpath ( $filepath ), 'image/jpeg' )
];
} else {
//不可使用CURLFile,及舊模式
$filedata = [
'fieldname' => '@'.realpath($filepath)
];
}
參考:http://www.maoyupeng.com/wechat-upload-image-errorcode-41005.html