图片:
视频:
model代码:
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;
}
}
|