当前位置:Gxlcms > PHP教程 > thinkphp-在ThinkPHP框架里如何实现在视图层选择要下载的文件?

thinkphp-在ThinkPHP框架里如何实现在视图层选择要下载的文件?

时间:2021-07-01 10:21:17 帮助过:7人阅读

框架thinkphpphp

这是上传函数和上传路径

 class FileController extends Controller{    public function upload(){        $upload = new \Think\Upload();// 实例化上传类        $upload->maxSize   =     0 ;// 附件上传大小        $upload->exts      =     array('jpg','gif','png','jpeg');// 附件上传类型        $upload->rootPath  =     './ueditor/php/upload/image/'; // 附件上传目录        $upload->saveName  =     'com_create_guid';// 采用GUID序列命名        $info=$upload->upload();        if(!$info){            $this->error($upload->getError());        }else{            foreach($info as $file){                $this->success($file['savepath'].$file['savename']."上传成功!",'',3);            }        }        $model = M('File');        $data['savename'] = $info[0]['savename'];        $data['create_time'] = NOW_TIME;        $model->add($data);    }

这是download.html

         下载    

人气教程排行