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
    }
}


点赞(0)

评论列表 共有 0 条评论

暂无评论