一款实例的php图片加水印,切头像图和自动缩放代码,他可以把你上传的图片生成指定大小的效果图与可以对图片进行自动切剪,下面看实例,代码如下:
-
<html>
-
<head>
-
<meta http-equiv="content-type" content="text/html; charset=gb2312">
-
<meta name="author" content="verdana core, phpdoc.net inc.">
-
<title>上传文件测试</title>
-
</head>
-
<body>
-
<form method=post enctype="multipart/form-data" action="<?php echo url_for("upload/webimages",true);?>">
-
<input type="file" name="upload" id="upload" onchange="preview()"; />
-
<br /><br />
-
<input type="submit" value="上传图片">
-
</form>
-
</body>
-
</html>
-
-
http:
-
-
frameworklibimg.class.php中的img类
-
-
<?
-
-
-
-
-
-
class uploadrouter extends controller{
-
function index()
-
{
-
-
}
-
function webimages()
-
{
-
print_r($_files);
-
$img=c("img");
-
$img->setinfo(
-
array("files"=>"upload",
-
"uploadpath"=>$globals['config']['webprojectpath']."upimages/",
-
"icopath"=>$globals['config']['webprojectpath']."upimages/",
-
"icowidth"=>"128",
-
"icoheight"=>"98",
-
"fangpath"=>$globals['config']['webprojectpath']."upimages/_ico/",
-
"fangsize"=>"75",
-
"nzsize"=>"180",
-
"uploadsize"=>420000
-
)
-
)->setbasename($_files['upload']['name'],true)->init();
-
-
-
if($img->upload(array('fix_side')))
-
{
-
echo("上传成功");
-
}else{
-
echo("上传失败");
-
echo $img->message;
-
}
-
return false;
-
}
-
}
-
?>
-