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

WBOY
Release: 2016-06-02 11:28:54
Original
929 people have browsed it

框架thinkphpphp

这是上传函数和上传路径

<code> 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);    }</code>
Copy after login

这是download.html

<code>     <meta charset="UTF-8">    <title>下载</title>    <link href="__PUBLIC__/css/download.css" rel="stylesheet" type="text/css">
<form method="get">    <table>        <tr>            <td><a href="__APP__/Home/File/download/id/%7B%24id%7D">下载</a></td>        </tr>    </table>
</form></code>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!