7.0之后的版本不在支持 CURLOPT_SAFE_UPLOAD 了,只能使用 CURLFile 。
if (class_exists('\CURLFile')) { // 这里用特性检测判断php版本
$data = array('file' => new \CURLFile(realpath($filedata))); //>=7.0
} else {
if (defined('CURLOPT_SAFE_UPLOAD')) {
curl_setopt($curl, CURLOPT_SAFE_UPLOAD, false);
$data = array('file' => '@' . realpath($filedata));//<=5.5
}
}
发表评论 取消回复