Blogger Information
Blog 6
fans 0
comment 0
visits 8896
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
tp6 多文件上传
过夜茶
Original
1389 people have browsed it
public function uploadMore(){
    // 获取表单上传文件  前端以imglist[]字段上传
    $files = request()->file();    
    //上传失败验证
    if(!$files){
        TApiException('上传失败',20009,200);
    }
    try {
    //文件验证,如果上传其它exe后缀文件,比如图标竟然验证通过??
     $res=validate(['imglist'=>'fileSize:102400|fileExt:jpg,png])
            ->check($files);
        foreach($files as $file) {
            $savename[] = \think\facade\Filesystem::disk('public')->putFile( 'topic', $file);
        }
        return $savename;
    } catch (\think\exception\ValidateException $e) {
        TApiException($e->getMessage(),20009,200);//抛出异常
    }

}


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post