/**
* 單文件上傳
* @param array
* @return string
*/
function upload_one($param,$type=0)
{
$upload = new \Think\Upload();
// $upload->maxSize? =? 2097152;? //字節(jié) 1KB=1024字節(jié) 默認為2M
$upload->maxSize? =? 102097152;? //字節(jié) 1KB=1024字節(jié) 200M
if($type==1){
//圖片和視頻
$upload->exts? ? ? =? array('flv','mp4','rmvb','avi','mpeg','ra','ram','mov','wmv');
}elseif($type==2){
$upload->exts? ? ? =? array('mp3', 'wav', 'wma', 'ogg','ape','acc'); //音頻
}else{
$upload->exts? ? ? =? array('jpg', 'gif', 'png', 'jpeg');
}
$upload->savePath? =? $param['savePath']; //保存路徑 相對路徑
$upload->subName? =? $param['subName'];? //子目錄
// $upload->saveName? =? $param['saveName']; //保存名稱
$upload->saveName? =? array('uniqid',$param['saveName']); //保存名稱 (uniqid有重復的可能)
$upload->saveExt? =? $param['saveExt'];? //保存后綴
$upload->replace? =? true; //存在同名的文件 覆蓋
$info? =? $upload->uploadOne($param['files']);
// print_r($info);
if(!$info)
{
// print_r($upload->getError());exit;
return 'error';
}else{
return $info['savepath'].$info['savename'];
}
}
/**
* 多文件上傳
* @param array
* @return string
*/
function multi_upload2($param,$type=0){
$upload = new \Think\Upload();
$upload->maxSize? =? 102097152;? //字節(jié) 1KB=1024字節(jié) 默認為200M
$upload->exts? ? ? =? array('jpg', 'gif', 'png', 'jpeg','mp3', 'wav', 'wma', 'ogg','ape','acc','flv','mp4','rmvb','avi','mpeg','ra','ram','mov','wmv');
$upload->savePath? =? $param['savePath']; //保存路徑 相對路徑
$upload->subName? =? $param['subName'];? //子目錄
$upload->saveName? =? array('uniqid',$param['saveName']); //保存名稱 (uniqid有重復的可能)
$upload->saveExt? =? $param['saveExt'];? //保存后綴
$upload->replace? =? true; //存在同名的文件 覆蓋
// 上傳文件
$info? =? $upload->upload($param['files']);? //顯示上傳文件,參數為空會有異常
if(!$info) {
// 上傳錯誤提示錯誤信息
return 'error';
}else{
// 上傳成功 獲取上傳文件信息
foreach($info as $file){
$returPath[]=$file['savepath'].$file['savename'];
}
return $returPath;
}
}