i'm using a http upload for transferring a javascript file to the server. however, fire开发者_C百科fox sends the content with the mime type set to 'x-c'. opera 11 is better in assuming 'application/x-javascript' but still incorrect. as i'd prefer to avoid server-side mime type detection, is there any chance to override mime-type detection for specific file extensions (namely '.js') or to provide hints to the browser algorithm ?
the ideal solution would be cross-browser ( at least ff 3.6, ie8, chrome 8 should be supported ). however, as a first step a solution limited to firefox would be welcome, too.
platform details: ff 3.6.13 on winxp sp3
uploaded file: jquery 1.4.4 ( uncompressed and minified versions ), elementary test files all files have the .js extension
thanks in advance for your efforts.
best regards, carsten
Now with html5 you can read file properties using the JavaScript File API, this way you can do things like checking the MIME type, the name or the file size. Unfortunately its only available in Firefox and Chrome fir the moment.
<input type="file" name="file" id="file" />
var file = document.getElementById('file').files[0];
then you can check the file properties with
file.name // The file name
file.size // The file size in bytes
file.type // The MIME-Type Eje:'audio/mp3'
精彩评论