Home  >  Article  >  Backend Development  >  How to obtain thinkphp3.2.3 upload file path

How to obtain thinkphp3.2.3 upload file path

PHP中文网
PHP中文网Original
2017-03-24 15:27:443752browse

thinkphp3.2.3 How to get the path of uploaded files:

First enter the code

//  导入excel
     public function upload(){       $upload = new \Think\Upload();// 实例化上传类
       $upload->maxSize   =     3145728 ;// 设置附件上传大小
       $upload->exts      =     array('xlsx','xls');// 设置附件上传类型
       $upload->rootPath  =      './Uploads/'; // 设置附件上传根目录
       $upload->savePath  =      ''; // 设置附件上传(子)目录
       // 上传文件
       $info   =   $upload->upload();       if(!$info) {// 上传错误提示错误信息
           $this->error($upload->getError());
       }else{// 上传成功 获取上传文件信息
           foreach($info as $file){               $FilePath = $file['savePath'].$file['savename'];
           }
           dump($FilePath);
       }
     }

The page output content
string(17) "57a9841cc3208.xls"
Just the file name

I want to get the path of this file as shown below

How to obtain thinkphp3.2.3 upload file path

ORZ, who can teach me

Reply content:

$upload->savePath 或 $upload->rootPath

How to obtain thinkphp3.2.3 upload file path

The above is the content of how to get the path of uploaded files in thinkphp3.2.3. For more related content, please pay attention to the PHP Chinese website (www.php.cn) !

Related articles:

How to get thinkphp3.2.3 upload file path

Thinkphp3.2.3 integrates phpqrcode to generate QR code sample code sharing

PHP implements uploading files without page refresh

Usage Html5 implements asynchronous file upload, supports cross-domain, and has upload progress bar

Statement:
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