// php5.6开始干掉了@语法,php上传图片兼容版本写法

if (class_exists(‘\CURLFile’)) {
curl_setopt($curl, CURLOPT_SAFE_UPLOAD, true);
$data = array(‘file’ => new \CURLFile(realpath($destination)));//5.5+
} else {
if (defined(‘CURLOPT_SAFE_UPLOAD’)) {
curl_setopt($curl, CURLOPT_SAFE_UPLOAD, false);
}
$data = array(‘file’ => ‘@’ . realpath($destination));//<=5.5
}

分类: web

标签:   php