Re: Uploading file and restricted filetypes!

From: Date: Tue, 06 May 2003 19:22:22 +0000
Subject: Re: Uploading file and restricted filetypes!
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-146549@lists.php.net to get a copy of this message
On Wednesday 07 May 2003 02:27, Frank Keessen wrote: > Can you please take a look at my script > > - Why is it not giving errors when i'm uploading something other than the > restricted filetypes.. (It now uploads everything). Because after you've assigned something to $error_message you don't use it. > if (!$error_message){ > if ($type == "image/x-png"){ > $extension=".png"; > }elseif ($type == "image/pjpeg"){ > $extension=".jpg"; > }elseif ($type == "image/gif"){ > $extension=".gif"; > }else{ > $error_message="Alleen .jpg of .jpeg of .gif of .png toegestaan"; > } Better to replace the above with a switch construct: /* Untested */ $error_message=''; switch ($type) { case 'image/x-png' : $extension=".png"; break; case 'image/pjpeg' : $extension=".jpg"; break; case 'image/gif' : $extension=".gif"; break; default : $error_message="Alleen .jpg of .jpeg of .gif of .png toegestaan"; } if ($error_message) { ... } -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * ------------------------------------------ Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general ------------------------------------------ /* I would like to know What I was fencing in And what I was fencing out. -- Robert Frost */

« previous php.general (#146549) next »