|
@@ -12,15 +12,14 @@ class Upload extends Controller
|
|
|
$file = request()->file('file');
|
|
$file = request()->file('file');
|
|
|
|
|
|
|
|
$fileInfo = $file->getInfo();
|
|
$fileInfo = $file->getInfo();
|
|
|
- /*if($fileInfo['size'] > 1024 * 1024 * 2){
|
|
|
|
|
|
|
+ if($fileInfo['size'] > 1024 * 512 * 2){
|
|
|
// 上传失败获取错误信息
|
|
// 上传失败获取错误信息
|
|
|
- return json( ['code' => -2, 'data' => '', 'msg' => '文件超过2M'] );
|
|
|
|
|
- }*/
|
|
|
|
|
|
|
+ return json( ['code' => -2, 'data' => '', 'msg' => '文件超过0.5M'] );
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
//检测图片格式
|
|
//检测图片格式
|
|
|
- $ext = explode('.', $fileInfo['name']);
|
|
|
|
|
|
|
+ $ext = explode('/', $fileInfo['type']);
|
|
|
$ext = array_pop($ext);
|
|
$ext = array_pop($ext);
|
|
|
-
|
|
|
|
|
$extArr = explode('|', 'jpg|png|gif|jpeg');
|
|
$extArr = explode('|', 'jpg|png|gif|jpeg');
|
|
|
if(!in_array($ext, $extArr)){
|
|
if(!in_array($ext, $extArr)){
|
|
|
return json(['code' => -3, 'data' => '', 'msg' => '只能上传jpg|png|gif|jpeg的文件']);
|
|
return json(['code' => -3, 'data' => '', 'msg' => '只能上传jpg|png|gif|jpeg的文件']);
|