thinkphp3.1 多文件上传图片和文档,如何保存在不同的文件夹

WBOY
Release: 2016-06-13 12:00:22
Original
957 people have browsed it

thinkphp3.1 多文件上传图片和文档,怎么保存在不同的文件夹?
thinkphp3.1 上传图片和文档,怎么分开保存?
------解决方案--------------------
如果你愿意修改 UploadFile.class.php 文件的话,事情还是有转机的
把 getSaveName 方法中的(408行附近)
$saveName = $rule().".".$filename['extension'];
改成
$saveName = $rule($filename).".".$filename['extension'];

然后

$upload->savePath = '';<br />$upload->saveRule = 'myFunction';
Copy after login

定义函数
function myFunction($filename) {<br />  $p = in_array($filename['extension'], array('gif', 'jpg', 'png')) ? '图片路径' : '文档路径';<br />  return $p . $filename['name'];<br />}
Copy after login

由于之后还会加上后缀,所以 $filename['name'] 怎么变形你可随意

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!