thinkphp upload图片上传能不能将缩略图和原图分别放在不同文件夹
publicfunctionuploadPic(){$config=array('maxSize'=>0,//上传的文件大小限制(0-不做限制)'exts'=>array...
public function uploadPic(){
$config = array(
'maxSize' => 0, //上传的文件大小限制 (0-不做限制)
'exts' => array('jpg','png','gif','jpeg'), //允许上传的文件后缀
'rootPath' => './Uploads/', //保存根路径
'driver' => 'LOCAL', // 文件上传驱动
'subName' => array('date', 'Y-m-d'),
'savePath' => I('dir','uploads')."/"
);
$upload = new \Think\Upload($config);
$rs = $upload->upload($_FILES);
if(!$rs){
$this->error($upload->getError());
}else{
$images = new \Think\Image();
$images->open('./Uploads/'.$rs['Filedata']['savepath'].$rs['Filedata']['savename']);
$newsavename = str_replace('.','_thumb.',$rs['Filedata']['savename']);
$vv = $images->thumb(I('width',100), I('height',100),I('thumb_type',1))->save('./Uploads/'.$rs['Filedata']['savepath'].$newsavename);
$rs['Filedata']['savepath'] = "Uploads/".$rs['Filedata']['savepath'];//缩略图显示路径
$rs['Filedata']['savethumbname'] = $newsavename;
$rs['status'] = 1;
echo json_encode($rs);
}
}
要在哪里改才可以让缩略图和原图放着不同文件夹下,菜鸟级别的我头好晕,现在生成的路径是,uploads->zx->时间->,我要的就是在时间下建两个文件夹,一个放原图,一个放缩略图, 展开
$config = array(
'maxSize' => 0, //上传的文件大小限制 (0-不做限制)
'exts' => array('jpg','png','gif','jpeg'), //允许上传的文件后缀
'rootPath' => './Uploads/', //保存根路径
'driver' => 'LOCAL', // 文件上传驱动
'subName' => array('date', 'Y-m-d'),
'savePath' => I('dir','uploads')."/"
);
$upload = new \Think\Upload($config);
$rs = $upload->upload($_FILES);
if(!$rs){
$this->error($upload->getError());
}else{
$images = new \Think\Image();
$images->open('./Uploads/'.$rs['Filedata']['savepath'].$rs['Filedata']['savename']);
$newsavename = str_replace('.','_thumb.',$rs['Filedata']['savename']);
$vv = $images->thumb(I('width',100), I('height',100),I('thumb_type',1))->save('./Uploads/'.$rs['Filedata']['savepath'].$newsavename);
$rs['Filedata']['savepath'] = "Uploads/".$rs['Filedata']['savepath'];//缩略图显示路径
$rs['Filedata']['savethumbname'] = $newsavename;
$rs['status'] = 1;
echo json_encode($rs);
}
}
要在哪里改才可以让缩略图和原图放着不同文件夹下,菜鸟级别的我头好晕,现在生成的路径是,uploads->zx->时间->,我要的就是在时间下建两个文件夹,一个放原图,一个放缩略图, 展开
2015-09-18
展开全部
$rs['Filedata']['savepath'] = "Uploads/缩略图名称/".$rs['Filedata']['savepath'];//缩略图显示路径
你试试
你试试
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询