PHP判断上传文件类型
程序员文章站
2024-02-19 12:10:16
...
PHP判断上传文件类型,很实用的,可以判断.csv格式
<?php
$allowedExtensions = array("txt","csv","htm","html","xml",
"css","doc","xls","rtf","ppt","pdf","swf","flv","avi",
"wmv","mov","jpg","jpeg","gif","png");
foreach ($_FILES as $file) {
if ($file['tmp_name'] > '') {
if (!in_array(end(explode(".",
strtolower($file['name']))),
$allowedExtensions)) {
die($file['name'].' is an invalid file type!<br/>'.
'<a href="javascript:history.go(-1);">'.
'<< Go Back</a>');
}
}
}
?>
上一篇: JSP 获取spring容器中bean的两种方法总结
下一篇: 20210202 Dos命令学习笔记