《PHP應(yīng)用:thinkPHP3.2簡(jiǎn)單實(shí)現(xiàn)文件上傳的方法》要點(diǎn):
本文介紹了PHP應(yīng)用:thinkPHP3.2簡(jiǎn)單實(shí)現(xiàn)文件上傳的方法,希望對(duì)您有用。如果有疑問(wèn),可以聯(lián)系我們。
相關(guān)主題:thinkphp教程
本文實(shí)例講述了thinkPHP3.2簡(jiǎn)單實(shí)現(xiàn)文件上傳的辦法.分享給大家供大家參考,具體如下:PHP編程
IndexController.class.php:PHP編程
<?php namespace Home\Controller; use Think\Controller; class IndexController extends Controller { function index(){ $this->display(); } public function upload(){ $upload = new \Think\Upload();// 實(shí)例化上傳類 $upload->maxSize = 3145728 ;// 設(shè)置附件上傳大小 $upload->exts = array('jpg', 'gif', 'png', 'jpeg');// 設(shè)置附件上傳類型 $upload->rootPath = './Uploads/'; // 設(shè)置附件上傳根目錄 $upload->savePath = ''; // 設(shè)置附件上傳(子)目錄 // 上傳文件 $info = $upload->upload(); print_r($info);exit; if(!$info) {// 上傳錯(cuò)誤提示錯(cuò)誤信息 $this->error($upload->getError()); }else{// 上傳成功 $this->success('上傳成功!'); } } } ?>
index.html:PHP編程
在view里建個(gè)和控制器同名的文件夾 Index 再建個(gè)和辦法同名的html index文件,這里省略.PHP編程
補(bǔ)充:小編在這里推薦一款本站的php格式化美化的排版工具贊助大家在以后的PHP程序設(shè)計(jì)中進(jìn)行代碼排版:
PHP編程
php代碼在線格式化美化工具:ode/phpformatPHP編程
更多關(guān)于thinkPHP相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《ThinkPHP入門教程》、《ThinkPHP常用辦法總結(jié)》、《smarty模板入門基礎(chǔ)教程》及《PHP模板技術(shù)總結(jié)》.PHP編程
希望本文所述對(duì)大家基于ThinkPHP框架的PHP程序設(shè)計(jì)有所贊助.PHP編程
轉(zhuǎn)載請(qǐng)注明本頁(yè)網(wǎng)址:
http://www.fzlkiss.com/jiaocheng/6630.html