Curl upload image problem, caused by php version

php5.5 and below: 
'imageFile' =>'@'. realpath($fileName), 

php5.6 and above: 
'imageFile' => new \CURLFile(realpath($fileName)),

final plan:

if (class_exists('\CURLFile')) {
    $field = array('fieldname' => new \CURLFile(realpath($filepath)));
} else {
    $field = array('fieldname' => '@' . realpath($filepath));
}

 

Guess you like

Origin blog.csdn.net/weixin_38230961/article/details/110088695