Reputation: 17581
I have php 5.3 and use finfo to determine the MIME type of uploaded files. For some javascript files however, I get mime type text/x-c++, which is of course incorrect.
Does anyone have an idea why this happens sometimes. Because of this, I cannot allow uploads of JS-files in a way based on checking the mime type.
The contents of a file that returns this mime type is:
(function($) {
$(document).ready(function() {
$(function() {
// OPACITY OF BUTTON SET TO 50%
$(".fade").css("opacity","1.0");
// ON MOUSE OVER
$(".fade").hover(function () {
// SET OPACITY TO 100%
$(this).stop().animate({
opacity: 0.7
}, "quick");
},
// ON MOUSE OUT
function () {
// SET OPACITY BACK TO 50%
$(this).stop().animate({
opacity: 1.0
}, "quick");
});
});
// End of closure & jquery wraping
});
})(jQuery);
Upvotes: 0
Views: 1778
Reputation: 25763
I ran into the same issue the other day (with PDF files being uploaded as application/data), as far as I know this is a browser issue and not a server side one, as I had two browsers upload the exact same PDF, one said application/PDF and the other application/data, my only suggestion to you use since checking the content type is somewhat flaky, you should do your own type checking.
For your case, I would just ensure that the mime type starts with "text/", and check the file extension of the uploaded file. If you're particularlly brave you may write some code that does a syntax check of the uploaded file, but that's probably going to be a lot more work than you want to do.
Upvotes: 1