123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- <?php
- declare (strict_types = 1);
- namespace app\Admin\controller;
- use app\BaseController;
- use think\Request;
- use think\facade\Filesystem;
- class Upload extends BaseController
- {
- /**
- * 显示资源列表
- *
- * @return \think\Response
- */
- public function index()
- {
- $post =$this->request->post();
- $token = isset($post['token']) ? trim($post['token']) : "";
- if($token==""){
- return error_show(101,'token不能为空');
- }
- $effetc = VerifyTokens($token);
- if(!empty($effetc) && $effetc['code']!=0){
- return error_show($effetc['code'],$effetc['message']);
- }
- $files = $this->request->file('image');
- $list="";
- if($files!=""){
- $list=UploadImg($files);
- }
- if(is_array($list)&&!empty($list)){
- return app_show(0, "上传成功!",$list);
- }else{
- return error_show(1005, "上传失败!".$list);
- }
- }
- /**
- * 显示创建资源表单页.
- *
- * @return \think\Response
- */
- public function create()
- {
- //
- }
- /**
- * 保存新建的资源
- *
- * @param \think\Request $request
- * @return \think\Response
- */
- public function save(Request $request)
- {
- //
- }
- /**
- * 显示指定的资源
- *
- * @param int $id
- * @return \think\Response
- */
- public function read($id)
- {
- //
- }
- /**
- * 显示编辑资源表单页.
- *
- * @param int $id
- * @return \think\Response
- */
- public function edit($id)
- {
- //
- }
- /**
- * 保存更新的资源
- *
- * @param \think\Request $request
- * @param int $id
- * @return \think\Response
- */
- public function QRDLoad()
- {
- $files = $this->request->file('file');
-
- try {
- validate([
- 'file' => [
- // 限制文件大小(单位b),这里限制为4M
- //fileSize' => 4 * 1024 * 1024,
- 'fileExt' => 'xlsx,xls'
- ]
- ],
- [
- //'file.fileSize' => '文件太大',
- 'file.fileExt' => '不支持的文件',
- ]
- )->check(['file' => $files]);
- $savename = Filesystem::disk('public')->putFileAs('topic/QRD', $files,"qrd.".$files->getOriginalExtension
- ());
- shell_exec("php /data/invoice/think qrdupload");
- return ['code' => 0, "msg" =>'确认单上传成功,数据在导入'];
- } catch (think\exception\ValidateException $e) {
- // echo $e->getMessage();
- return ['code' => 1003, "msg" => $e->getMessage()];
- }
- }
- /**
- * 删除指定资源
- *
- * @param int $id
- * @return \think\Response
- */
- public function CGDLoad()
- {
- $files = $this->request->file('file');
- try {
- validate([
- 'file' => [
- // 限制文件大小(单位b),这里限制为4M
- //fileSize' => 4 * 1024 * 1024,
- 'fileExt' => 'xlsx,xls'
- ]
- ],
- [
- //'file.fileSize' => '文件太大',
- 'file.fileExt' => '不支持的文件',
- ]
- )->check(['file' => $files]);
- $savename = Filesystem::disk('public')->putFileAs('topic/CGD', $files,"cgd.".$files->getOriginalExtension());
- shell_exec("php /data/invoice/think cgdupload");
- return ['code' => 0, "msg" =>'采购单上传成功,数据在导入'];
- } catch (think\exception\ValidateException $e) {
- // echo $e->getMessage();
- return ['code' => 1003, "msg" => $e->getMessage()];
- }
- }
- }
|