Created
December 20, 2015 09:54
-
-
Save gautamkrishnar/bf7f3e00ad9b3703e7ae to your computer and use it in GitHub Desktop.
file extension fiter for file upload
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//upload code | |
$filename=$_FILE['name']['filename_in_html']; //you can change this with your filename | |
$allowed='png,jpg'; //which file types are allowed seperated by comma | |
$extension_allowed= explode(',', $allowed); | |
$file_extension= pathinfo($filename, PATHINFO_EXTENSION); | |
if(array_search($file_extension, $extension_allowed)) | |
{ | |
echo "$extension_allowed allowed for uploading file"; | |
} | |
else | |
{ | |
echo "$extension_allowed is not allowed for uploading file"; | |
} | |
//Rem $filename=$_FILE['name']['filename_in_html']; //you can change this with your filename | |
$allowed='png,jpg'; //which file types are allowed seperated by comma | |
$extension_allowed= explode(',', $allowed); | |
$file_extension= pathinfo($filename, PATHINFO_EXTENSION); | |
if(array_search($file_extension, $extension_allowed)) | |
{ | |
echo "$extension_allowed allowed for uploading file"; | |
} | |
else | |
{ | |
echo "$extension_allowed is not allowed for uploading file"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment