摘要:参考看了一下文档。了解了一下多文件上传等等。<?php namespace app\index\controller; use think\facade\Request; use think\Controller; use app\index\model\Cate; class Index extends Control
参考看了一下文档。了解了一下多文件上传等等。
<?php namespace app\index\controller; use think\facade\Request; use think\Controller; use app\index\model\Cate; class Index extends Controller { public function demo() { if (request()->isPost()) { $res = Request::file('file'); // dump($res);die; if(is_null($res)) { $this->error('不能为空'); } $rule=['ext'=>'jpg']; $fileinfo=$res->validate($rule)->move('uploads'); //获取文件路径 $filepath = '/uploads/'.$fileinfo->getSaveName(); } return $this->view->fetch(); } }
批改老师:韦小宝批改时间:2018-11-30 09:11:29
老师总结:多文件上传还没学会的话可以找一下每日小知识PHP篇来看看!我在这套课中有讲过多文件上传哦!