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

PHP中TP5 上傳文件的實(shí)例詳解

 更新時(shí)間:2017年07月31日 10:09:34   作者:onestopweb  
這篇文章主要介紹了PHP中TP5 上傳文件的實(shí)例詳解的相關(guān)資料,這里實(shí)現(xiàn)PHP 的上傳文件的實(shí)例,需要的朋友可以參考下

php 文件上傳

效果圖:

實(shí)現(xiàn)代碼:

application\index\controller\Index.php

<?php 
namespace app\index\controller; 
use think\Controller; 
use think\Request; 
class Index extends Controller 
{ 
  //文件上傳表單 
  public function index() 
  { 
    return $this->fetch(); 
  } 
  //文件上傳提交 
  public function upload() 
  { 
    //獲取表單上傳文件 
    $file = request()->file('files'); 
    if (emptyempty($file)) { 
      $this->error('請(qǐng)選擇上傳文件'); 
    } 
    //移動(dòng)到框架應(yīng)用根目錄/public/uploads/ 目錄下 
    $info = $file->move(ROOT_PATH . 'public' . DS . 'uploads'); 
    if ($info) { 
      $this->success('文件上傳成功'); 
      echo $info->getFilename(); 
    } else { 
      //上傳失敗獲取錯(cuò)誤信息 
      $this->error($file->getError()); 
    } 
  } 
} 

 application\index\view\index\index.html

<!doctype html> 
<html> 
<head> 
<meta charset="UTF-8"> 
<title>文件上傳</title> 
</head> 
<body> 
<h2>文件上傳</h2> 
<FORM method="post" enctype="multipart/form-data" class="form" action="{:url('upload')}">選擇文件: 
  <INPUT type="file" class="files" name="files"><br/> 
  <INPUT type="submit" class="btn" value=" 提交 "> 
</FORM> 
</body> 
</html> 

以上就是php上傳文件的實(shí)例,如有疑問請(qǐng)留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!

相關(guān)文章

最新評(píng)論