更新时间:2022-11-27 15:51:25
使用 if( $ext !== 'gif'
) 可能效率不高.如果您允许 20 个不同的扩展名怎么办?
Using if( $ext !== 'gif'
) might not be efficient. What if you allow like 20 different extensions?
试试:
$allowed = array('gif', 'png', 'jpg');
$filename = $_FILES['video_file']['name'];
$ext = pathinfo($filename, PATHINFO_EXTENSION);
if (!in_array($ext, $allowed)) {
echo 'error';
}