TP5(thinkPHP5框架)基于bootstrap實(shí)現(xiàn)的單圖上傳插件用法示例
本文實(shí)例講述了TP5(thinkPHP5框架)基于bootstrap實(shí)現(xiàn)的單圖上傳插件用法。分享給大家供大家參考,具體如下:
1-引入js文件和css文件
<!--圖片上傳--> <link href="/public/static/css/bootstrap.min.css" rel="external nofollow" rel="stylesheet"> <link href="/public/static/css/fileinput.css" rel="external nofollow" media="all" rel="stylesheet" type="text/css" /> <script src="/public/static/js/jquery-2.0.3.min.js"></script> <script src="/public/static/js/fileinput.js" type="text/javascript"></script> <script src="/public/static/js/fileinput_locale_de.js" type="text/javascript"></script> <script src="/public/static/js/bootstrap.min.js" type="text/javascript"></script>
2-html代碼
<div class="form-group"> <label for="inputPassword3" class="col-sm-2 control-label">輪播圖</label> <div class="col-sm-10"> <input class="file" type="file" name="img"> </div> </div>
3-控制器
public function add() { $file = $request->file("img"); //聲明一個(gè)空的文件路徑 $imgPath = ""; //移動(dòng)文件到框架應(yīng)用更目錄的public/uploads/ if ($file) { $info = $file->move(ROOT_PATH . 'public' . DS . 'upload' . DS . 'top_bar' . DS . date('Y') . DS . date('m-d'),md5(microtime(true))); if ($info) { $imgPath = "/public/upload/top_bar/" . date('Y') . '/' . date('m-d') . '/' . $info->getSaveName(); } } else { //錯(cuò)誤提示用戶(hù) return $this->error($file->getError()); } //賦值 $data["thumb_url"] = $imgPath; $dataId = Db::name('top_bar')->insertGetId($data); }
更多的功能和插件 參考地址:https://www.kancloud.cn/he_he/thinkphp5/787173
更多關(guān)于thinkPHP相關(guān)內(nèi)容感興趣的讀者可查看本站專(zhuān)題:《ThinkPHP入門(mén)教程》、《thinkPHP模板操作技巧總結(jié)》、《ThinkPHP常用方法總結(jié)》、《codeigniter入門(mén)教程》、《CI(CodeIgniter)框架進(jìn)階教程》、《Zend FrameWork框架入門(mén)教程》及《PHP模板技術(shù)總結(jié)》。
希望本文所述對(duì)大家基于ThinkPHP框架的PHP程序設(shè)計(jì)有所幫助。
- springboot整合jquery和bootstrap框架過(guò)程圖解
- python設(shè)計(jì)微型小說(shuō)網(wǎng)站(基于Django+Bootstrap框架)
- 在Bootstrap開(kāi)發(fā)框架中使用dataTable直接錄入表格行數(shù)據(jù)的方法
- React BootStrap用戶(hù)體驗(yàn)框架快速上手
- Bootstrap框架建立樹(shù)形菜單(Tree)的實(shí)例代碼
- 基于Bootstrap框架菜鳥(niǎo)入門(mén)教程(推薦)
- 使用vue框架 Ajax獲取數(shù)據(jù)列表并用BootStrap顯示出來(lái)
- BootStrap前端框架使用方法詳解
相關(guān)文章
php獲取數(shù)據(jù)庫(kù)中數(shù)據(jù)的實(shí)現(xiàn)方法
下面小編就為大家?guī)?lái)一篇php獲取數(shù)據(jù)庫(kù)中數(shù)據(jù)的實(shí)現(xiàn)方法。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-06-06CakePHP框架Model關(guān)聯(lián)對(duì)象用法分析
這篇文章主要介紹了CakePHP框架Model關(guān)聯(lián)對(duì)象用法,結(jié)合實(shí)例形式分析了cakePHP框架Model關(guān)聯(lián)對(duì)象的功能、定義及具體使用方法,需要的朋友可以參考下2017-08-08thinkphp5?操作redis?實(shí)現(xiàn)文章的熱度排行和點(diǎn)贊排行的示例
本文主要介紹了thinkphp5?操作redis?實(shí)現(xiàn)文章的熱度排行和點(diǎn)贊排行的示例,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2022-04-04Symfony頁(yè)面的基本創(chuàng)建實(shí)例詳解
這篇文章主要介紹了Symfony頁(yè)面的基本創(chuàng)建實(shí)例詳解,詳細(xì)分析了Symfony頁(yè)面的具體創(chuàng)建流程與注意事項(xiàng),需要的朋友可以參考下2015-01-01PHP文件緩存smarty模板應(yīng)用實(shí)例分析
這篇文章主要介紹了PHP文件緩存smarty模板應(yīng)用方法,結(jié)合實(shí)例形式較為詳細(xì)的分析了smarty模板緩存的相關(guān)使用技巧,需要的朋友可以參考下2016-02-02PHP計(jì)算一年多少個(gè)星期和每周的開(kāi)始和結(jié)束日期
這篇文章主要介紹了PHP計(jì)算每周的開(kāi)始和結(jié)束日期,php實(shí)現(xiàn)計(jì)算一年多少周,同時(shí)計(jì)算出每一周的開(kāi)始日期和結(jié)束日期,需要的朋友可以參考下2014-07-07