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条)

报告相同问题?

悬赏问题

  • ¥20 iOS绕地区网络检测
  • ¥15 python验证码滑块图像识别
  • ¥15 根据背景及设计要求撰写设计报告
  • ¥15 QT6颜色选择对话框显示不完整
  • ¥20 能提供一下思路或者代码吗
  • ¥15 用twincat控制!
  • ¥15 请问一下这个运行结果是怎么来的
  • ¥15 单通道放大电路的工作原理
  • ¥30 YOLO检测微调结果p为1
  • ¥15 DS18B20内部ADC模数转换器