I am having a hard time with my image upload script, getting the images to upload in Internet Explorer. I have been searching Google for a solution and adding the "image/pjpeg" mime type seemed to work for everyone, but I have added it to my code and still cannot get it to work.
Here is what I have:
$acceptedExts = array ('jpg','jpeg');
if ( in_array($ext,$acceptedExts)
&& ( $_FILES["uploaded_file"]["type"] == "image/pjpeg"
|| $_FILES["uploaded_file"]["type"] == "image/jpeg")
&& ($_FILES["uploaded_file"]["size"] < 16000000)) {
Am I doing anything wrong?
Thanks!
Try a
var_dump($_FILES['uploaded_file'])
to see exactly what IE's sending. It may beimage/jpg
or something completely different. However, it's bad form to use the user-provided['type']
field for validation. It's trivial to forge that value. Better use a server-side method to figure out file type, such asget_image_size()
or theFileInfo
library, both of which return the true mime-type of the file.