ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
php ``` if ($this->request->isPost()) { $file_get = $_FILES['file']; //获取文件 $file_name = $file_get['name']; //文件名 if (!$_FILES['file']['tmp_name']||!$_FILES['file']['name']){ $this->error('请选择文件'); } $fs_lswn = $file_get['tmp_name']; $fs_site = "../public/{$file_name}"; // 要上传的文件地址 $filename = move_uploaded_file($fs_lswn,$fs_site); //上传图像 if($filename){ $this->success('文件上传成功!'); }else{ $this->error("失败:{$file_name}-{$filename}"); } } ``` html ``` <form class="layui-form" method="post" enctype="multipart/form-data"> <div class="layui-form-item"> <label class="layui-form-label">文件</label> <div class="layui-input-block"> <input type="file" name="file" class="layui-input"> <div class="layui-form-mid layui-word-aux">为保证安全,仅支持上传txt、jpg、png、ico文件</div> </div> </div> <div class="layui-form-item"> <div class="layui-input-block"> <button class="layui-btn" type="submit" lay-submit lay-filter="*">立即提交</button> </div> </div> </form> ```