i'm trying to upload file using php. i want to restrict the file extensions to .jpg and jpeg. this is the code i have
...
how do i make use of an array that has the specifics extensions to be used?
There are some options. You are mentioning an array which is of course one potential solution.
<?php
$validExt = array('jpg', 'jpeg', 'png');
$extension = array_pop(explode('.', $_FILES[0]['name'])); // replace this with your version of the FILES array
$extension = strtolower($extension); // make it all lower case
if (in_array($extension, $validExt)) {
// here comes the code for a valid JPEG ... file
} else {
// here comes the code for an invalid file
}
?>
Regards
Maba