跪求PHP上传图片并按比例缩放到一定尺寸的程序,非常感谢
1个回答
2014-09-22
展开全部
public function upimges(){
$filename = time();
header("Content-Type:text/html;charset=utf-8");
$upload = new Upimage('','','','',$filename);
//设置上传文件大小
$upload->maxSize = 100000000000000 ;
// $upload->saveRule =microtime().'_'.mt_rand(1000,9999);
//上传文件命名规则time uniqid com_create_guid 等
// $upload->$saveRule = time() ;
//设置上传文件类型
$upload->allowExts = explode(',','jpg,gif,png,jpeg');
//设置附件上传目录
$upload->savePath = './data/attached/skp/'.$_SESSION['formtoken'].'/';
$upload->thumb = true;
// 设置引用图片类库包路径
$upload->imageClassPath = './Image.php';
//设置需要生成缩略图的文件后缀
$upload->thumbPrefix = 'thumb_,thumbm_,thumbl_,thumbs_';//生产4张缩略图
//设置缩略图最大宽度
$upload->thumbMaxWidth = '960,480,120,64';
//设置缩略图最大高度
$upload->thumbMaxHeight = '960,480,120,64';
//删除原图
$upload->thumbRemoveOrigin = false;
if(!$upload->upload()) {
$data['tip'] = $upload->getErrorMsg();
$data['status'] = '0';
}else{
$info = $upload->getUploadFileInfo();
$data['counts'] = count($info);
$data['status'] = '1';
$data['tip'] = '上传成功';
$data['info'] = $info;
}
echo json_encode($data);
}
这个是代码和所引用的
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询