Php Validate File Type

[Solved] Php Validate File Type | Shell - Code Explorer | yomemimo.com
Question : php validate file type

Answered by : literate-lentil

// 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 : https://stackoverflow.com/questions/10456113/check-file-extension-in-upload-form-in-php | Last Update : Wed, 15 Jun 22

Question : validate file exist php

Answered by : helpless-hamster-4lza2i2jlz5q

Input : echo file_exists('/user01/work/gfg.txt');
Output : 1
Input : $file_pointer = '/user01/work/gfg.txt'; if (file_exists($file_pointer)) { echo "The file $file_pointer exists"; }else { echo "The file $file_pointer does not exists"; }
Output : 1

Source : https://www.geeksforgeeks.org/php-file_exists-function/ | Last Update : Wed, 23 Feb 22

Answers related to php validate file type

Code Explorer Popular Question For Shell