【问题标题】:php upload not working to get .vcf file type [closed]php上传无法获取.vcf文件类型[关闭]
【发布时间】:2015-03-23 17:17:09
【问题描述】:

您好,我无法使其正常工作,正在寻求帮助。

这是我当前的代码:

$accepted_file_mime_types = array('image/gif','image/jpg','image/jpeg','image/png','application/pdf','application/zip','application/vnd.openxmlformats-officedocument.wordprocessingml.document','application/msword','text/plain','audio/wav','audio/mp3','audio/mp4');
$file_extension = strtolower(strrchr($_FILES["userpro_file"]["name"], "."));

if( !in_array($file_extension, array( '.gif','.jpg','.jpeg','.png','.pdf','.txt','.zip','.doc','.docx','.wav','.mp3','.mp4'  )  ) || !in_array($fileinfo,$accepted_file_mime_types) ){
 // .. Do stuff
}

这是我尝试过的代码,但仍然给我无效文件类型的错误:

$accepted_file_mime_types = array('image/gif','image/jpg','image/jpeg','image/png','application/pdf','application/zip','application/vnd.openxmlformats-officedocument.wordprocessingml.document','application/msword','text/plain','audio/wav','audio/mp3','audio/mp4', 'text/x-vcard');
$file_extension = strtolower(strrchr($_FILES["userpro_file"]["name"], "."));
if( !in_array($file_extension, array( '.gif','.jpg','.jpeg','.png','.pdf','.txt','.zip','.doc','.docx','.wav','.mp3','.mp4','.vcf'  )  ) || !in_array($fileinfo,$accepted_file_mime_types) ){
    // do stuff
}

任何帮助将不胜感激。 谢谢。

【问题讨论】:

    标签: php types upload mime


    【解决方案1】:

    vCard 文件的 mimetype 为

    text/vcard 
    

    您需要将其添加为accepted_file_mime_types 之一。如果不是这样,它可能是以下任何一种 mimetype,现在是 deprecated。

    text/x-vcard
    text/directory;profile=vCard
    text/directory 
    

    编辑 - 如果还是不行,你需要在上传文件时输出 mimetype 看看需要接受什么。

    【讨论】:

      【解决方案2】:

      尝试text/vcard 的 MIME 类型。 text/x-vcard 已弃用。

      【讨论】:

      • 适合我的 mime 类型是 vcard
      猜你喜欢
      • 2014-05-19
      • 1970-01-01
      • 2020-03-17
      • 2012-09-16
      • 2011-03-14
      • 2015-02-06
      • 2014-04-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多