Server IP : 51.89.169.208 / Your IP : 18.222.106.93 Web Server : Apache System : Linux ns3209505.ip-198-244-202.eu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Tue Nov 5 04:50:16 EST 2024 x86_64 User : yellowleaf ( 1019) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/yellowleaf/public_html/staff/edit/ |
Upload File : |
<?php function img_up($fieldname,$destination,$image_file,$width,$height,$watermark){ // some settings $max_upload_width = 2592; $max_upload_height = 1944; // if user chosed properly then scale down the image according to user preferances if($width<=$max_upload_width){ $max_upload_width = $width; } if($height<=$max_upload_height){ $max_upload_height = $height; } // if uploaded image was JPG/JPEG if($_FILES[$fieldname]["type"] == "image/jpg" || $_FILES[$fieldname]["type"] == "image/jpeg" || $_FILES[$fieldname]["type"] == "image/pjpeg"){ $image_source = imagecreatefromjpeg($_FILES[$fieldname]["tmp_name"]); } // if uploaded image was GIF if($_FILES[$fieldname]["type"] == "image/gif"){ $image_source = imagecreatefromgif($_FILES[$fieldname]["tmp_name"]); } // if uploaded image was PNG if($_FILES[$fieldname]["type"] == "image/png"){ $image_source = imagecreatefrompng($_FILES[$fieldname]["tmp_name"]); } // watermark list($wm_width, $wm_height) = getimagesize($_FILES[$fieldname]["tmp_name"]); if($wm_width<$max_upload_width || $wm_height<$max_upload_height){ if($watermark==TRUE){ $watermark_image = imagecreatefrompng('img/watermark.png'); imagecopy($image_source, $watermark_image, $wm_width-130, $wm_height-30, 0, 0, imagesx($watermark_image),imagesy($watermark_image)); } } $remote_file = $destination.$image_file; imagejpeg($image_source,$remote_file,100); chmod($remote_file,0644); // get width and height of original image list($image_width, $image_height) = getimagesize($remote_file); if($image_width>$max_upload_width || $image_height >$max_upload_height){ $proportions = $image_width/$image_height; /// FIXED DIMENSIONS // $new_width = 300; $new_height = 150; $new_image = imagecreatetruecolor($new_width , $new_height); $image_source = imagecreatefromjpeg($remote_file); imagecopyresampled($new_image, $image_source, 0, 0, 0, 0, $new_width, $new_height, $image_width, $image_height); // watermark if($watermark==TRUE){ $watermark_image = imagecreatefrompng('img/watermark.png'); imagecopy($new_image, $watermark_image, $new_width-130, $new_height-30, 0, 0, imagesx($watermark_image),imagesy($watermark_image)); } imagejpeg($new_image,$remote_file,100); imagedestroy($new_image); } imagedestroy($image_source); } ?>