简体   繁体   中英

why is the mime-type of an uploaded .appcache or .manifest file — “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"

It's unlikely that your computer (or Firefox) associates the file extensions .appcache and .manifest with MIME type text/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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM