Re: filtering filename.ext on file-upload.

From: Date: Fri, 16 Jan 2004 02:27:39 +0000
Subject: Re: filtering filename.ext on file-upload.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-174752@lists.php.net to get a copy of this message
try this, it works for me: if ($_FILES['imagefile']['type'] != "image/pjpeg") { print("File must be a .jpg. File will not be accepted; please choose a .jpg picture or convert the picture to .jpg format."); unlink($filename); // This will remove the temporary file so we don't have to deal with it anymore. } move_uploaded_file($filename, $newfilename); -- a little different approach... it says if it is not a jpg, do not upload it, otherwise upload it.... "Louie Miranda" <louie@axishift.ath.cx> wrote in message news:050d01c3dbd5$f7e4f480$027d2fac@admwebdevws... > How can you filter the extension for files being uploaded on a system via > form. > > here are my codes: > > ## code ## > $catchfile = $_FILES['userfile']['name']; > $uploaddir = '/var/www-upload'; > $uploadfile = $uploaddir . $catchfile; > if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) { > ## code ## > > > > -- - > Louie Miranda > http://www.axishift.com

« previous php.general (#174752) next »