Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php validate file type

// get extension of file name:
pathinfo($filename, PATHINFO_EXTENSION);

// validate for array of allowed file types:
$allowed = array('gif', 'png', 'jpg');
$filename = $_FILES['video_file']['name'];
$ext = pathinfo($filename, PATHINFO_EXTENSION);
if (!in_array($ext, $allowed)) {
    echo 'error';
}
Comment

PREVIOUS NEXT
Code Example
Php :: if condition in smarty 
Php :: string array to array in php 
Php :: php get file location 
Php :: yii2 dataprovider to model 
Php :: Target class [BannerController] does not exist. 
Php :: invalid_taxonomy 
Php :: laravel show table columns 
Php :: how to check confirm password in php 
Php :: laravel new line in language file 
Php :: array filter multiple conditions php 
Php :: php rand vs mt_rand 
Php :: Array to XML Conversion using PHP 
Php :: php check if text is blank 
Php :: laravel get file in public folder 
Php :: drupal 8 get enabled languages 
Php :: PHP strstr — Find the first occurrence of a string 
Php :: limiting requests to controllers in laravel 
Php :: change the date format in laravel view page 
Php :: laravel cache put array 
Php :: php code for video upload 
Php :: guzzle Request with POST files 
Php :: php tomorrow 
Php :: PHP str_split — Convert a string to an array 
Php :: laravel update from 7 to 8 
Php :: php check if associative array 
Php :: laravel model events 
Php :: string match percentage php 
Php :: APP_DEBUG is set to true while APP_ENV is not local 
Php :: get server ip php 
Php :: how hide empty category woocommerce wordpress 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =