php ics 文件 MIME 类型
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2164176/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ics file mime type
提问by musoNic80
I'm trying to upload an ics file to my site. It was exported from iCal on Mac OSX. I thought that ics files had a mime type of text/calendar, but for some reason this file seems to be of type Application/octet-stream. This makes the upload fail my verification tests. Anyone have any ideas why the type isn't what I expect?!
我正在尝试将 ics 文件上传到我的网站。它是从 Mac OSX 上的 iCal 导出的。我认为 ics 文件的 mime 类型为text/calendar,但由于某种原因,该文件似乎是Application/octet-stream. 这使得上传无法通过我的验证测试。任何人都知道为什么类型不是我所期望的?!
采纳答案by Pekka
The MIME type is determined by the browser, and seemingly, your browser doesn't know the proper MIME type for an ics file. Never mind, just skip the MIME check and do some structural analysis (Is there a valid header, are any calendar records present, etc.)
MIME 类型由浏览器决定,看起来,您的浏览器不知道 ics 文件的正确 MIME 类型。没关系,只需跳过 MIME 检查并进行一些结构分析(是否有有效的标题,是否存在任何日历记录等)
The MIME type is of very limited use for validation anyway, as it can be freely modified by the client.
MIME 类型无论如何用于验证的用途非常有限,因为它可以由客户端自由修改。
回答by jckdnk111
Try adding a content-typeof text/calendarto the header.
If you are just serving it up from Apache you can look for instruction here: http://httpd.apache.org/docs/1.3/mod/mod_mime.html
尝试添加内容类型的text/calendar到头部。如果您只是从 Apache 提供它,您可以在此处查找说明:http: //httpd.apache.org/docs/1.3/mod/mod_mime.html
回答by Abraham Sewill
I'll add my two cents. Browsers in general look at the headers the server sends them to determine MIME type. If no MIME type is sent by the server, good browsers guess, all IE generally do not. The link to the apache docs above posted by jckdnk111 is a good resource.
我会加上我的两分钱。浏览器通常会查看服务器发送给它们的标头以确定 MIME 类型。如果服务器没有发送 MIME 类型,好的浏览器会猜测,所有 IE 一般都没有。jckdnk111 发布的上述 apache 文档的链接是一个很好的资源。

