大家好我所有的上传文档都有问题 我已经通过php验证了上传文件
function uploadanyfile($fileName){
$allowedExts = array("pdf","doc","docx","png","jpg","jpeg","gif","GIF","ppt","pptx","PNG","JPEG","JPG","psd","txt","xlsx","xls","rtf");$refrenext=explode(".", $_FILES["$fileName"]["name"]);
$extension = end($refrenext);
if ( (
($_FILES["$fileName"]["type"] == "application/pdf") ||
($_FILES["$fileName"]["type"] == "application/acrobat") ||
($_FILES["$fileName"]["type"] == "application/x-pdf") ||
($_FILES["$fileName"]["type"] == "application/msword") ||
($_FILES["$fileName"]["type"] == "application/rtf") ||
($_FILES["$fileName"]["type"] == "application/vnd.ms-excel") ||
($_FILES["$fileName"]["type"] == "application/vnd.ms-powerpoint") ||
($_FILES["$fileName"]["type"] == "application/vnd.openxmlformats-officedocument.presentationml.presentation") ||
($_FILES["$fileName"]["type"] == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") ||
($_FILES["$fileName"]["type"] == "application/vnd.openxmlformats-officedocument.wordprocessingml.document") ||
($_FILES["$fileName"]["type"] == "image/psd") ||
($_FILES["$fileName"]["type"] == "application/psd") ||
($_FILES["$fileName"]["type"] == "text/plain") ||
($_FILES["$fileName"]["type"] == "application/photoshop") ||
($_FILES["$fileName"]["type"] == "image/photoshop") ||
($_FILES["$fileName"]["type"] == "image/PJPEG") ||
($_FILES["$fileName"]["type"] == "image/pjpeg") ||
($_FILES["$fileName"]["type"] == "image/PNG") ||
($_FILES["$fileName"]["type"] == "image/png") ||
($_FILES["$fileName"]["type"] == "image/GIF") ||
($_FILES["$fileName"]["type"] == "image/gif") ||
($_FILES["$fileName"]["type"] == "image/jpeg") ||
($_FILES["$fileName"]["type"] == "image/JPG") ||
($_FILES["$fileName"]["type"] == "image/jpg") ) &&
in_array($extension, $allowedExts))
{
if ($_FILES["$fileName"]["error"] > 0)
{
$retuva= 'error in uploading may be the file type is not supported.!!';
}
else
{
$retuva= 'Success1230';
}
} else {
$retuva= 'file not uploaded !! Invalid file type.';
}
return $retuva;
}
该功能运行良好,但问题是当我尝试上传任何其他扩展的ppt或doc,如pptx或csv等函数说无效文件我知道原因但我无法列出任何可能的值一个doc文件可以在mac或windows中有数百个扩展名。
我可以获得帮助,我可以允许所有可能的上传仅限制可能损害我的服务器lke .php或exe文件的文件......?