TP5 图片上传
public function uploads()
{
$file = request()->file('file');
$arr = [];
if ($file) {
$info = $file->validate(['size' => 1024*1024, 'ext' => 'jpg,png,gif'])->move(ROOT_PATH . 'public' . DS . 'uploads');
if ($info) {
$arr['code'] = 1;
$arr['msg'] = $info->getSaveName();
} else {
$arr['code'] = 2;
$arr['msg'] = $file->getError();
}
}else{
$arr['code']=3;
$arr['msg'] ="上传错误";
}
return $arr;
}
浙公网安备 33010602011771号