file extension validation

From: Date: Fri, 19 Apr 2002 04:09:50 +0000
Subject: file extension validation
Groups: php.general 
Request: Send a blank email to php-general+get-93726@lists.php.net to get a copy of this message
Here is what I have currently to validate the file type on upload to a server: <?php if ($htm1 != "" && eregi('.htm$', $htm1)) { @copy("$htm1", "/path/to/upload/directory/$htm1") or die ("Could not upload file, please try again after making sure the file is less than 2mb in size and the file name correct"); } else { die("No file selected for upload, or the file was not the correct type. Please only upload .htm files."); } ?> Right now it just checkes the file extension, I would like to know how I can use this piece of code and add the functionality of actually checking the file first. If anyone can point me in the right direction that would be great. Thanks in advance, Jas

« previous php.general (#93726) next »