2. Process page upload_img.php
-
-
//Upload image saving address - $uploadfile = "upfiles/".$_FILES['upfile']['name'];
- //Thumbnail saving Address
- $smallfile = "upfiles/small_".$_FILES['upfile']['name'];
- if($_FILES['upfile']['type'] ! = "image/jpeg")
- {
- echo 'Wrong file type';
- }
- else
- {
- move_uploaded_file($_FILES['upfile']['tmp_name'],$uploadfile); //Upload file p>
$dstW=200;//Thumbnail width
- $dstH=200;//Thumbnail height
$src_image=ImageCreateFromJPEG($uploadfile);
- $srcW =ImageSX($src_image); //Get the image width
- $srcH=ImageSY($src_image); //Get the image height
$dst_image=ImageCreateTrueColor($dstW,$dstH);
- ImageCopyResized($dst_image,$src_image,0,0,0,0,$dstW,$dstH,$srcW,$srcH);
- ImageJpeg($dst_image,$smallfile);
echo 'File uploaded successfully ';
- echo "";
- }
- ?>
-
Copy the code
the above code, It is relatively simple. Friends who are interested can study the gd library function in the PHP manual.
|