Program If you are familiar with PHP's GD library, it is not difficult to read this article!
<?php
/******************************************************************************
Parameter description:
$max _file_size: Upload file size limit, unit byte
$destination _folder: Upload file path
$watermark: Whether additional watermark (1 for Watermark, other for no watermark);
Instructions for use:
1. Remove the "Extension=php_gd2.dll" line in front of the php.ini file, because we need to use the GD library;
2. Change Extension_dir = to the directory where your Php_gd2.dll is located;
******************************************************************************/
$max _file_size=2000000; Upload file size limit, unit byte
$destination _folder= "uploadimg/"; Upload file path
$watermark = 1; Whether to add watermark (1 for Watermark, other for no watermark);
$watertype = 1; Watermark Type (1 for text, 2 for picture)
$waterposition = 1; Watermark position (1 is lower left corner, 2 is lower right corner, 3 is upper left corner, 4 is upper right corner, 5 is centered);
$waterstring = "http://www.xplore.cn/"; Watermark String
$waterimg = "Xplore.gif"; Watermark Picture
$imgpreview = 1; Whether to generate a preview diagram (1 is a build, others are not generated);
$imgpreviewsize =1/2; Thumbnail proportions
?>
<title>zwell Image Upload Program </title>
<style type= "Text/css" >
<!--
Body
{
font-size:9pt;
}
Input
{
Background-color: #66CCFF;
border:1px inset #CCCCCC;
}
-->
</style>
<?php
if ($_server[' request_method '] = = ' POST ')
{
if (!is_uploaded_file ($_files["Upfile"][tmp_name))
Is there a file
{
echo "Picture does not exist!";
Exit
}
$file = $_files["Upfile"];
if ($max _file_size < $file ["size"])
Check File size
{
echo "file is too big!";
Exit
}
if (!in_array ($file ["type"], $uptypes))
Check file type
{
echo "file type does not match!". $file [' type '];
Exit
}
if (!file_exists ($destination _folder))
{
mkdir ($destination _folder);
}
$filename = $file ["Tmp_name"];
$image _size = getimagesize ($filename);
$pinfo =pathinfo ($file ["name"]);
$ftype = $pinfo [' extension '];
$destination = $destination _folder.time (). "." $ftype;
if (file_exists ($destination) && $overwrite!= True)
{
echo "file with the same name already exists";
Exit
}
if (!move_uploaded_file ($filename, $destination))
{
echo "Move file Error";
Exit
}
Visitor, Hello! Transfer to Netcom Station | Switch to Telecom station building block Home | More than 500 kinds of Web page effects finishing | Practical Query Function Manual | Block network bt Download Alliance | Classic Jokes | Radio Stations | High-definition classic picture material
Program development web design search engine special effects code operating system Protection virus hacker technology graphic image Computer hardware network technology Server database net article pristine
Your location: Home >> program development Channel >> PHP >> body: Title: PHP Classic to the Image plus Watermark Program (2) Time: 2006-8-7 Source: Cool Network Dynamics browse Number: 7 times $pinfo =pathinfo ($destination);
$fname = $pinfo [basename];
echo "<font color=red> has been successfully uploaded </font><br> FileName: <font color=blue>". $destination _folder. $fname. " </font><br> ";
echo "width:". $image _size[0];
echo "Length:". $image _size[1];
echo "<br> size:". $file ["Size"]. "bytes";
Switch ($iinfo [2])
{
Case 1:
Imagegif ($nimage, $destination);
Imagejpeg ($nimage, $destination);
Break
Case 2:
Imagejpeg ($nimage, $destination);
Break
Case 3:
Imagepng ($nimage, $destination);
Break
Case 6:
Imagewbmp ($nimage, $destination);
Imagejpeg ($nimage, $destination);
Break
}
Overwrite original upload file
Imagedestroy ($nimage);
Imagedestroy ($simage);
}
if ($imgpreview ==1)
{
echo "<br> picture preview:<br>";
echo "echo "alt=\" Picture preview: \ r filename: ". $destination." \ r upload time: \ ">";
}
}
?>
</body>
Finally, I think it is necessary to add a watermark to the image principle:
Get uploaded file information, create a true color image, assign a color scheme, and populate the image.
Create a graphic by determining the type of file, and then copy it to the original set of graphics, fill and build the rectangle to write imagestring () or the original image
The program to determine the watermark type: One is a string, another is to add a graphic object on top.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.