Private function _upload($path,$width,$height){
import('ORG.Net.UploadFile');
$obj=new UploadFile();
$obj->maxSize=5000000;
$obj->savePath='./Uploads/'.$path.'/';
$obj->saveRule='uniqid';
$obj->uploadReplace=true;
$obj->allowExts=array('jpeg','jpg','png','gif');
$obj->thumb=true;
$obj->thumbType=0;
$obj->thumbMaxWidth=$width;
$obj->thumbMaxHeight=$height;
$obj->thumbPrefix='max_,medium_,mini_';
$obj->thumbPath=$obj->savePath.date('Y_m').'/';
$obj->thumbRemoveOrigin=true;
$obj->autoSub=true;
$obj->subType='date';
$obj->dateFormat='Y_m';
if (!$obj->upload()) {
$this->error($obj->getErrorMsg());
}else{
$info=$obj->getUploadFileInfo();
foreach ($info as $v) {
$savename[]=$v['savename'];
}
foreach ($savename as $v) {
$pic[]=explode('/', $v);
}
foreach ($pic as $v) {
$save[]=array(
'face400'=>$v[0].'/max_'.$v[1],
'face240'=>$v[0].'/medium_'.$v[1],
'face140'=>$v[0].'/mini_'.$v[1]
);
}
return $save;
}
}这是上传方法:Public function upload(){
if(!IS_POST) halt('The page is not exist');
$title=$_POST['title'];
$copyright=$_POST['copyright'];
$upload=$this->_upload('Pic','400,240,140','1000,1000,1000');
$sql='SELECT * FROM `sbg_article` order by time desc limit 1';
$result=M('article')->query($sql);
$showtime=$result[0]['time'];
$count=count($upload);
for ($i=0; $i <$count ; $i++) {
$user[$i]=array(
'title'=>ucwords($title[$i]),
'time'=>time(),
'pic400'=>$upload[$i]['face400'],
'pic240'=>$upload[$i]['face240'],
'pic140'=>$upload[$i]['face140'],
'showtime'=>$showtime+mt_rand(($i+1)*1200,($i+1)*2200),
'copyright'=>$copyright[$i],
'up'=>mt_rand(100,300),
'down'=>mt_rand(20,100)
);
M('article')->data($user[$i])->add();
}
$this->success('OK!');
}给它生成3幅缩略图,但是全都变成取第一帧了 最佳答案