note 69816 added to function.imagejpeg

From: Date: Fri, 22 Sep 2006 01:24:14 +0000
Subject: note 69816 added to function.imagejpeg
Groups: php.notes 
Request: Send a blank email to php-notes+get-117401@lists.php.net to get a copy of this message
This is simple function for uploading images... what it's useful for? Even if the source image is PNG or GIF, the same it will be saved as JPG. <?php uploadimage($HTTP_POST_FILES['userfile'],"path/somejpegfile.jpg"); ?> <?php function uploadimage($user, $destination) { echo "$userfile xxxx $destination"; if($user['name']) { $filename = $user['name']; if (($pos = strrpos($filename, ".")) === FALSE) { //echo "Error - file doesn't have a dot... weird."; } else { $extension = substr($filename, $pos + 1); //echo $extension; // will echo "jpeg" } $lextension = strtolower($extension); echo " $extension"; if(file_exists($destination)) unlink($destination); if(move_uploaded_file($user['tmp_name'], $destination)) echo "&nbsp;success"; else echo "&nbsp;unsucceess"; //chmod("$destination",0777); if(($lextension == "jpg") or ($lextension == "jpeg")) { } elseif($lextension == "gif") { $ima = imagecreatefromgif($destination); unlink($destination); imagejpeg($ima, $destination, 100); } elseif($lextension == "png") { $ima = imagecreatefrompng($destination); unlink($destination); imagejpeg($ima, $destination, 100); } chmod($destination,0777); } } ?> ---- Server IP: 147.32.160.17 Probable Submitter: 84.42.174.55 ---- Manual Page -- http://www.php.net/manual/en/function.imagejpeg.php Edit -- https://master.php.net/note/edit/69816 Del: integrated -- https://master.php.net/note/delete/69816/integrated Del: useless -- https://master.php.net/note/delete/69816/useless Del: bad code -- https://master.php.net/note/delete/69816/bad+code Del: spam -- https://master.php.net/note/delete/69816/spam Del: non-english -- https://master.php.net/note/delete/69816/non-english Del: in docs -- https://master.php.net/note/delete/69816/in+docs Del: other reasons-- https://master.php.net/note/delete/69816 Reject -- https://master.php.net/note/reject/69816 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#117401) next »