function upload_file_to_oss($furl, $url, $data = array()) {
$handle = fopen($furl, "r"); //使用打开模式为r
$file = fread($handle, filesize($furl)); //读为二进制
// debug($data);
if ($data) {
$data['file'] = $file;
}
// 初始化
$ch = curl_init();
// 设置变量
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0); //执行结果是否被返回,0是返回,1是不返回
curl_setopt($ch, CURLOPT_HEADER, 0); //参数设置,是否显示头部信息,1为显示,0为不显示
//表单数据,是正规的表单设置值为非0
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 100); //设置curl执行超时时间最大是多少
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
ob_start();
$result = curl_exec($ch);
// $output = ob_get_contents();
$output = ob_get_contents();
$info = curl_getinfo($ch);
// debug(curl_getinfo($ch));
ob_end_clean();
curl_close($ch);
if ($result) {
return $info['http_code'] == 200 ? true : false;
} else {
return false;
}
}