hi all

i m using below multiple upload code but its not allowing me to upload images

if i remove file type check validation code then everything works fine

PHP Code:
<?php
$conn 
mysql_connect("localhost","root",'') or die(mysql_error());
mysql_select_db("test",$conn);
if(isset(
$_FILES['files'])){

    foreach(
$_FILES['files']['tmp_name'] as $key => $tmp_name ){
        
$file_name $key.$_FILES['files']['name'][$key];
        
$file_size =$_FILES['files']['size'][$key];
        
$file_tmp =$_FILES['files']['tmp_name'][$key];
        
$file_type=$_FILES['files']['type'][$key];    

        if(
$file_size 2097152){
            echo 
$file_name .' exceeds limit of 2 MB <br>';
            
$errors true;
        }

        if ( (
$file_type != "image/gif") || ($file_type != "image/jpeg") || ($file_type != "image/png") || ($file_type != "image/pjpeg") )
        {
        echo 
$file_name .' extension is not allowed <br>';
        
$errors true;
        }
        
        
//echo $query."<br>";
        
$desired_dir="multiple_images_folder";
        if(
$errors == false){
            if(
is_dir($desired_dir)==false){
                
mkdir("$desired_dir"0700);// Create directory if it does not exist
            
}
            if(
is_dir("$desired_dir/".$file_name)==false){
                
move_uploaded_file($file_tmp,"$desired_dir/".$file_name);
            }else{                                    
// rename the file if another one exist
                
$new_dir="$desired_dir/".$file_name.time();
                 
rename($file_tmp,$new_dir) ;                
            }
        
$query="INSERT into upload_data (file_name,file_size,file_type) VALUES('$file_name','$file_size','$file_type'); ";    
         
mysql_query($query);            
        }else{
                echo 
"there are some errors";
        }
    }
    if(
$errors == false){
        echo 
"Success";
    }
}
?>

<form action="" method="POST" enctype="multipart/form-data">
    <input type="file" name="files[]" /><br />
    <input type="file" name="files[]" /><br />
    <input type="file" name="files[]" /><br />
    <input type="file" name="files[]" /><br />
    <input type="submit" name="submit" value="upload multiple"/>
</form>
vineet