<html>
<head>
<title>ZwelL圖片上傳程序</title>
<style type=
<!
body
{
font
}
input
{
background
border:
}
</style>
</head>
<body>
<form enctype=
上傳文件:
<input name=
<input type=
允許上傳的文件類型為:<?=implode(
</form>
<?php
if ($_SERVER[
{
if (!is_uploaded_file($_FILES[
//是否存在文件
{
echo
exit;
}
$file = $_FILES[
if($max_file_size < $file[
//檢查文件大小
{
echo
exit;
}
if(!in_array($file[
//檢查文件類型
{
echo
exit;
}
if(!file_exists($destination_folder))
{
mkdir($destination_folder);
}
$filename=$file[
$image_size = getimagesize($filename);
$pinfo=pathinfo($file[
$ftype=$pinfo[
$destination = $destination_folder
if (file_exists($destination) && $overwrite != true)
{
echo
exit;
}
if(!move_uploaded_file ($filename
{
echo
exit;
}
$pinfo=pathinfo($destination);
$fname=$pinfo[basename];
echo
<font color=blue>
echo
echo
echo
if($watermark==
{
$iinfo=getimagesize($destination
$nimage=imagecreatetruecolor($image_size[
$white=imagecolorallocate($nimage
$black=imagecolorallocate($nimage
$red=imagecolorallocate($nimage
imagefill($nimage
switch ($iinfo[
{
case
$simage =imagecreatefromgif($destination);
break;
case
$simage =imagecreatefromjpeg($destination);
break;
case
$simage =imagecreatefrompng($destination);
break;
case
$simage =imagecreatefromwbmp($destination);
break;
default:
die(
exit;
}
imagecopy($nimage
imagefilledrectangle($nimage
switch($watertype)
{
case
imagestring($nimage
break;
case
$simage
imagecopy($nimage
imagedestroy($simage
break;
}
switch ($iinfo[
{
case
//imagegif($nimage
imagejpeg($nimage
break;
case
imagejpeg($nimage
break;
case
imagepng($nimage
break;
case
imagewbmp($nimage
//imagejpeg($nimage
break;
}
//覆蓋原上傳文件
imagedestroy($nimage);
imagedestroy($simage);
}
if($imgpreview==
{
echo
echo
height=
echo
}
}
?>
</body>
</html>
[
From:http://tw.wingwit.com/Article/program/PHP/201311/21465.html