note 69817 added to function.imagecreatefrompng

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

« previous php.notes (#117402) next »