将本地文件上传至服务器
class testController extends Mb{
public function index(){
$uper = t('uper','file','upload');//初始化,参数1=文件域-名,2=保存文件的目录
$uper->setAllow('image/png,image/jpeg,image/pjpeg,image/x-png,image/gif,video/mp4,audio/mpeg,application/vnd.ms-excel,application/x-zip-compressed','jpg,gif,png,mp4,mp3,xls,zip',20480);
$uploadedFile = $uper->upload();
if(!$uploadedFile){
$this->json('上传失败 : '.$uper->error,201);
}else{
$this->json('上传成功',200,['file_url'=>'/'.$uploadedFile,'file_name'=>$uper->fileName]);
}
}
}可以赞助并支持下作者哦,谢谢!