Php 上载允许格式的所有扩展名

Php 上载允许格式的所有扩展名,php,file-upload,upload,mime-types,Php,File Upload,Upload,Mime Types,大家好,我的php上传文档有问题 我已经通过类似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["$fi

大家好,我的php上传文档有问题 我已经通过类似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或任何其他扩展名(如pptx或csv等)的文档时,该功能会显示无效文件。我知道原因,但我无法列出任何特定文件的所有可能值。一个文档在mac或windows中可以有数百个扩展名


我可以得到一个帮助,我可以允许所有可能的上传只限制文件,这可能会损害我的服务器lke.php或exe文件

反转条件:检查禁止的扩展是否可以修改函数并让我知道所有有害扩展的可能扩展。真的,不是。你可以为此付出代价。顺便说一句,你原来的方法更好。