欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

TP5(thinkPHP5框架)基于bootstrap實(shí)現(xiàn)的單圖上傳插件用法示例

 更新時(shí)間:2019年05月29日 12:02:30   作者:qq_37138818  
這篇文章主要介紹了TP5(thinkPHP5框架)基于bootstrap實(shí)現(xiàn)的單圖上傳插件用法,結(jié)合實(shí)例形式分析了thinkPHP5框架結(jié)合bootstrap實(shí)現(xiàn)圖片上傳相關(guā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ò)誤提示用戶
  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)容感興趣的讀者可查看本站專題:《ThinkPHP入門教程》、《thinkPHP模板操作技巧總結(jié)》、《ThinkPHP常用方法總結(jié)》、《codeigniter入門教程》、《CI(CodeIgniter)框架進(jìn)階教程》、《Zend FrameWork框架入門教程》及《PHP模板技術(shù)總結(jié)》。

希望本文所述對大家基于ThinkPHP框架的PHP程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評論