为什么上传的 .appcache 或 .manifest 文件的 mime 类型是“application/octet-stream”?
我在表单上上传了一个文件,当我上传名为“theManifest.manifest”或“theManifest.appcache”的文件时,mime 类型不正确。
我在 php 代码中使用“echo”来告诉我已上传文件的详细信息 - 这是代码:
<form enctype="multipart/form-data" action="file-upload.php" method="POST">
Upload the manifest file:<input type="file" name="uploaded" id="id_upload" />
<input type="submit" value="Upload" />
</form>
这是告诉我文件是什么的 php 代码:
echo "<br> The file that was uploaded is as follows:";
echo "<br>uploaded_name = " . $_FILES['uploaded']['name'];
echo "<br>uploaded_size = " . $_FILES['uploaded']['size'];
echo "<br>uploaded_type = " . $_FILES['uploaded']['type'];
echo "<br>uploaded_tmp_name = " . $_FILES['uploaded']['tmp_name'];
echo "<br>uploaded_error = " . $_FILES['uploaded']['error'];
这是我得到的输出:
The file that was uploaded is as follows:
uploaded_name = theManifest.appcache
uploaded_size = 51
uploaded_type = application/octet-stream
uploaded_tmp_name = C:\xampp\tmp\php4064.tmp
uploaded_error = 0;
我只是不'不明白为什么在 Windows Vista 上运行的 Firefox 8 认为 .manifest 和 .appcache 文件都是 “application/octet-stream”的 MIME 类型。
以下是我的 .appcache 文件的内容,有时用 .manifest 重命名以测试此问题。
#This is a blank, test-cases-only, .manifest file.
这是一个带有注释(.manifest 样式注释)的文本文件,仅此而已。
知道为什么 MIME 类型是“application/octet-stream”吗???
据我所知,正确的 MIME 类型,即我应该在上面的代码中看到的报告 “text/cache-manifest”——而不是“application/octet-stream”
I have a file upload on a form and when I upload my file called "theManifest.manifest" or "theManifest.appcache" the mime-type is not correct.
I use 'echo' in my php code to tell me the details of the file that was uploaded -- here is the code:
<form enctype="multipart/form-data" action="file-upload.php" method="POST">
Upload the manifest file:<input type="file" name="uploaded" id="id_upload" />
<input type="submit" value="Upload" />
</form>
Here is the php code that tells me what the file is:
echo "<br> The file that was uploaded is as follows:";
echo "<br>uploaded_name = " . $_FILES['uploaded']['name'];
echo "<br>uploaded_size = " . $_FILES['uploaded']['size'];
echo "<br>uploaded_type = " . $_FILES['uploaded']['type'];
echo "<br>uploaded_tmp_name = " . $_FILES['uploaded']['tmp_name'];
echo "<br>uploaded_error = " . $_FILES['uploaded']['error'];
Here's the output I get:
The file that was uploaded is as follows:
uploaded_name = theManifest.appcache
uploaded_size = 51
uploaded_type = application/octet-stream
uploaded_tmp_name = C:\xampp\tmp\php4064.tmp
uploaded_error = 0;
I just don't see why Firefox 8 running on Windows Vista thinks that both the .manifest and .appcache files are
the MIME-type of "application/octet-stream".
Here are the contents of my .appcache file, renamed with .manifest at times to test this problem.
#This is a blank, test-cases-only, .manifest file.
This is a text file with a comment (.manifest-style comment) and nothing else.
Any idea why the MIME-type is "application/octet-stream" here ???
The correct MIME type, the one I should see reported in the code above -- is to the best of my knowledge
"text/cache-manifest" -- and not "application/octet-stream"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的计算机(或 Firefox)不太可能将文件扩展名
.appcache
和.manifest
与 MIME 类型text/cache-manifest
关联起来。这很可能并不重要。当浏览器下载文件时,这一点非常重要,因为如果没有正确的 MIME 类型,浏览器不会将该文件视为应用程序缓存清单。
但对于文件上传来说,MIME 类型对于应用程序缓存清单来说很可能并不重要,至少在通常情况下是这样。
It's unlikely that your computer (or Firefox) associates the file extensions
.appcache
and.manifest
with MIME typetext/cache-manifest
. And it is quite possibly unimportant.It matters a lot when the browser is downloading the file because without the correct MIME type, the browser won't treat the file as an appcache manifest.
But for a file upload, the MIME type is quite possibly unimportant for an appcache manifest, at least typically.