you can make an exception for that, generally most jpeg files are named .jpg but you can make a special exception for .jpeg.

PHP Code:
else if (substr($img_name,0,-4) == "jpeg"$img_exts) && $img_size $max_size


move_uploaded_file($img_temp_loc,"/images" $img_name); 


The above generally should be the first if statement because of the program logical flow, you normally start with the odd ball first because in this case its first going to check if the files extension is in the array thus iterating through the arrays values and then if its not there then check if its jpeg. The full notion would be

PHP Code:
<?php 

$img_exts 
= array("jpg","jpeg","png","gif","tiff","bmp"); // list of allowed file types 
$max_size 40000// max file size in bytes 

$img_size $_FILE["img"]["size"]; // returns the files size in bytes 

$img_type $_FILE["img"]["type"]; // returns the types as image/extenstions_here 

$img_name $_FILE["img"]["name"]; //returns the files name including extenstion 

$img_temp_loc $_FILE["img"]["tmp_name"]; // returns temp upload location of the image 

$img_err $_FILE["img"]["error"

/* start the process of the validation */ 

if ($img_err 0

 echo 
"There was an error uploading your image, please check to make sure the file is an image and try again."

else 


if (
substr($img_name,0,-4) == "jpeg"$img_exts) && $img_size $max_size


move_uploaded_file($img_temp_loc,"/images" $img_name); 

}
else if (
in_array(substr($img_name,0,-3), $img_exts) && $img_size $max_size


move_uploaded_file($img_temp_loc,"/images" $img_name); 



else 


echo 
"either your image was to big or the file was not a valid image files please correct this and try again."





?>
If you do you need to add an else if statement for that with the code to process it or do a conversion based on if its .jpeg to .jpg when your saving the file. Also I dont recommend using negatives in substr() because it may or may not work properly the best case would be to use:

PHP Code:
substr($text_var,strlen($text_var) - 3,strlen($text_var)); 
We use strlen() because it gives the length in numbers per character including white space of the string. In this case subtracting the number of points we wanted to from the end of the file and making it our start number and then using the total length as the end number gives us the same result but with an almost 100% guarantee to work properly over using negatives.

version using strlen()

PHP Code:
<?php 

$img_exts 
= array("jpg","jpeg","png","gif","tiff","bmp"); // list of allowed file types 
$max_size 40000// max file size in bytes 

$img_size $_FILE["img"]["size"]; // returns the files size in bytes 

$img_type $_FILE["img"]["type"]; // returns the types as image/extenstions_here 

$img_name $_FILE["img"]["name"]; //returns the files name including extenstion 

$img_temp_loc $_FILE["img"]["tmp_name"]; // returns temp upload location of the image 

$img_err $_FILE["img"]["error"

/* start the process of the validation */ 

if ($img_err 0

 echo 
"There was an error uploading your image, please check to make sure the file is an image and try again."

else 


if (
substr($img_name,strlen($img_name) - 4,strlen($img_name)) == "jpeg"$img_exts) && $img_size $max_size


move_uploaded_file($img_temp_loc,"/images" $img_name); 

}
else if (
in_array(substr($img_name,strlen($img_name) - 3,strlen($img_name)), $img_exts) && $img_size $max_size


move_uploaded_file($img_temp_loc,"/images" $img_name); 



else 


echo 
"either your image was to big or the file was not a valid image files please correct this and try again."





?>
shabbir like this