导入必要文件
编写html+js代码
使用gthinkphp5编写上传接口
public function uploadThumb() { $file = $this->request->file('file'); $info = $file->move(ROOT_PATH . 'public' . DS . 'uploads'); if ($info) { $result = [ 'code' => 0, 'msg' => '上传成功', 'filename' => '/public/uploads/' . str_replace('\\', '/', $info->getSaveName()) ]; } else { $result = [ 'code' => -1, 'msg' => $file->getError() ]; } return json($result); }
更多详情: