Thinkphp多文件上传实现方法
前端之家收集整理的这篇文章主要介绍了
Thinkphp多文件上传实现方法,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
<div class="codebody" id="code10222">protected $info= '';
protected $_auto = array(
array('image','upload',3,callback),//自动完成方法
array('video','videoupload',//自动完成方法
);//自动填充上传图片生成缩略图
protected function upload(){
$var = $_FILES['image']['name'];
import('ORG.Net.UploadFile');
$upload = new UploadFile();
$upload->saveRule = time;
$upload->allowExts = array('jpg','gif','png','zip','flv');
$upload->thumb = true;
//视频路径。。。只支持flv后缀,
$upload->videopath = './Public/upload/Video/';
$upload->savePath = './Public/upload/images/';
$upload->thumbPrefix = '250115,150110,213156';
$upload->thumbMaxWidth='250,150,213';
$upload->thumbMaxHeight='115,110,156';
if(!in_array('',$var) || !in_array('',$_FILES['video']['name'])){
if(!$upload->upload()) {
echo $upload->getErrorMsg();die;
}else{
$this->info = $upload->getUploadFileInfo();
if(!in_array('',$var) && !in_array('',$_FILES['video']['name'])){
return $this->info[1]['savename'];
}elseif(!in_array('',$var)){
return $this->info[0]['savename'];
}else{
return false;
}
}
}else{
return flase;
}
}
//上传视频
protected function videoupload(){
if(!in_array('',$_FILES['video']['name'])){
return $this->info[0]['savename'];
}elseif(!in_array('',$_FILES['video']['name'])){
return $this->info[1]['savename'];
}else{
return false;
}
}