改为
<li><input type='file' name='photo1'></li> <li><input type='file' name='photo2'></li> <li><input type='file' name='photo3'></li>
或者
<li><input type='file' name='photo[]'></li> <li><input type='file' name='photo[]'></li> <li><input type='file' name='photo[]'></li>
暂且自己的上传表单域为两个,一个上传图片,一个上传视频。字段名为image、video。
html代码如下
图片:<input type="file" name="image[]"> 视频:<input type="file" name="video[]">
protected $info= ''; protected $_auto = array( array('image','upload',3,callback),//自动完成方法 array('video','videoupload',3,callback), //自动完成方法 );//自动填充上传图片生成缩略图 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 = '250_115_,150_110_,213_156_'; $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('',$var) && !in_array('',$_FILES['video']['name'])){ return $this->info[0]['savename']; }elseif(!in_array('',$_FILES['video']['name'])){ return $this->info[1]['savename']; }else{ return false; } }
<li><input type='file' name='photo[]'></li> <li><input type='file' name='photo[]'></li> <li><input type='file' name='photo[]'></li>
protected $_auto = array( array('image','upload',3,callback),//自动完成方法 array('video','videoupload',3,callback), //自动完成方法 );//自动填充上传图片生成缩略图
希望本文所述对大家的ThinkPHP框架程序设计有所帮助。