Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR 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';
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #php #validate #file #type
ADD COMMENT
Topic
Name
2+7 =