如何使用ThinkPHP3.2实现与layui兼容的上传接口?
- 内容介绍
- 文章标签
- 相关推荐
本文共计207个文字,预计阅读时间需要1分钟。
ThinkPHP3.2 集成 layui 的上传接口,参数设置如下:上传文件大小限制为 3145728 字节,即 3MB。不限制文件大小,使用 `savePath` 指定保存路径为 `/Content/`,`rootPath` 指定根路径为 `/Upload/Content/`。保存文件名通过 `uniqid()` 函数生成,后缀名留空。
thinkphp3.2给layui写的上传接口3145728,//文件上传的最大文件大小(以字节为单位),0为不限大小 // 'savePath' => '/Content/', 'rootPath' => 'Upload/Content/', //保存根路径 'saveName' => array('uniqid',''), 'exts' => array('jpg', 'gif', 'png', 'jpeg'), 'autoSub' => true, 'subName' => array('date','Ymd'), ); $upload=new Upload($config); $info=$upload->upload(); if ($info){ foreach($info as $file){ $data['src']="/".$config['rootPath'].$file['savepath'].$file['savename']; } $this->toApi('0',"上传成功",$data); }else{ $this->toApi('1',$upload->getError()); } } }
本文共计207个文字,预计阅读时间需要1分钟。
ThinkPHP3.2 集成 layui 的上传接口,参数设置如下:上传文件大小限制为 3145728 字节,即 3MB。不限制文件大小,使用 `savePath` 指定保存路径为 `/Content/`,`rootPath` 指定根路径为 `/Upload/Content/`。保存文件名通过 `uniqid()` 函数生成,后缀名留空。
thinkphp3.2给layui写的上传接口3145728,//文件上传的最大文件大小(以字节为单位),0为不限大小 // 'savePath' => '/Content/', 'rootPath' => 'Upload/Content/', //保存根路径 'saveName' => array('uniqid',''), 'exts' => array('jpg', 'gif', 'png', 'jpeg'), 'autoSub' => true, 'subName' => array('date','Ymd'), ); $upload=new Upload($config); $info=$upload->upload(); if ($info){ foreach($info as $file){ $data['src']="/".$config['rootPath'].$file['savepath'].$file['savename']; } $this->toApi('0',"上传成功",$data); }else{ $this->toApi('1',$upload->getError()); } } }

