note 69818 added to function.imagecreatefromgif

From: Date: Fri, 22 Sep 2006 01:27:03 +0000
Subject: note 69818 added to function.imagecreatefromgif
Groups: php.notes 
Request: Send a blank email to php-notes+get-117403@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.imagecreatefromgif.php Edit -- https://master.php.net/note/edit/69818 Del: integrated -- https://master.php.net/note/delete/69818/integrated Del: useless -- https://master.php.net/note/delete/69818/useless Del: bad code -- https://master.php.net/note/delete/69818/bad+code Del: spam -- https://master.php.net/note/delete/69818/spam Del: non-english -- https://master.php.net/note/delete/69818/non-english Del: in docs -- https://master.php.net/note/delete/69818/in+docs Del: other reasons-- https://master.php.net/note/delete/69818 Reject -- https://master.php.net/note/reject/69818 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#117403) next »