douzhi9635 2013-04-18 15:44
浏览 26
已采纳

您可以通过PHP上传哪些文件类型?

I'm trying to find a reference that shows what the different names of the "TYPES" are like $_FILES["file"]["type"] == "image/gif" but I'm looking for the csv, ms excel, mac numbers, ms word, etc.

I can't find anything on php.net or google. I'm most likely calling it the wrong thing anyway.

What is it called that I should be looking for?

  • 写回答

3条回答 默认 最新

  • douwen7475 2013-04-18 16:02
    关注

    This is actually explained in the PHP Manual.

    From http://php.net/manual/en/features.file-upload.post-method.php (emphasis mine)

    $_FILES['userfile']['type']: The mime type of the file, if the browser provided this information. An example would be "image/gif". This mime type is however not checked on the PHP side and therefore don't take its value for granted.

    So the term you are looking for is MIME TYPE. Putting that into Google will likely make you end up at Wikipedia's https://en.wikipedia.org/wiki/Internet_media_type

    An Internet media type[1] is a two-part identifier for file formats on the Internet. The identifiers were originally defined in RFC 2046 for use in email sent through SMTP, but their use has expanded to other protocols such as HTTP, RTP and SIP. These types were called MIME types, and are sometimes referred to as Content-types, after the name of a header in several protocols whose value is such a type.

    The article also states

    IANA manages the official registry of media types

    Following the link will lead you to

    and that contains the list you are looking for. Note that looking at that list is mostly pointless unless you want to find out what an official mimetype for a particular file format is.

    On a side note: if you want to validate/detect the mime type of a file, check the code I have provided in

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置