quote:
Originally posted by leejeffery
well i learnt how 2 upload files (quite easy) but now i need to know how 2 limit the file type using php if this is possible
I assume you want to limit files based on their extensions? Here's some simple example code...
code:
<?php
$filename = "uploaded.txt";
$extension = substr(strrchr($filename, "."), 1);
if($extension == "php" || $extension == "php3") {
die("That file type is banned!");
}
?>
Or if you want to allow only certain types...
code:
if($extension != "jpg" && $extension != "gif") {
die("Only .jpg and .gif files are allowed!");
}
Of course, the $filename line has to be removed, and then on the line below that, you need to replace $filename with whatever variable your script uses.