Buonasera a tutti ho problema con il controllo del campo $_FILES anche se vuoto inserisce comunque un record nel database
codice HTML:
<div class="form-group">
        <label for="foto" class="col-sm-2 control-label">Immagini Correlate</label>
         <div class="col-sm-5">
               <input type="file" id="foto" accept="image/*" name="foto[]" multiple>
         </div> 
</div>
Codice PHP:
  if(!empty($_FILES['foto'])){
       
$errors= array();        
        foreach(
$_FILES['foto']['tmp_name'] as $key => $tmp_name ){            
            
$foto_name $_FILES['foto']['name'][$key];            
            
$foto_size $_FILES['foto']['size'][$key];            
            
$foto_tmp $_FILES['foto']['tmp_name'][$key];            
            
$foto_type$_FILES['foto']['type'][$key];            
            if(
$foto_size $providerMaxFileSize){                
                  
$errors[]='File size must be less than 4 MB'
           }
            if(empty(
$errors)==false{
                
print_r($errors);
            }else{
                if(
is_dir($user_data)==false){
                    
mkdir("$user_data",0777);
                 }
                if(
file_exists($user_data.$foto_name)==false{
                    
move_uploaded_file($foto_tmp,"$user_data".$foto_name);
                    
smart_resize_image($user_data.$foto_name,//input
                        
120,//larghezza
                        
120,//altezza
                        
true,//proporziona
                        
$user_data  "thumb-".$foto_name,//output
                        
false//cancella originale
                    
);
                }else{
                    
$name substr($foto_name0strrpos($foto_name'.'));
                    
$new_dir="$user_data";
                    
$new_name  $name time();
                    
$ultimoPunto strrpos($foto_name,".");
                    
$estensione=substr($foto_name,$ultimoPunto 1);
                    
$foto_name $new_name "." $estensione;
                    
move_uploaded_file($foto_tmp"$new_dir".$foto_name);
                    
smart_resize_image($new_dir.$foto_name,//input
                        
120,//larghezza
                        
120,//altezza
                        
true,//proporziona
                        
$user_data  "thumb-".$foto_name,//output
                        
false//cancella originale 
                   
);
                }
            }
            
$sql_foto "INSERT INTO immagini_corr_temp(idImage,immagine_corr) VALUES ('$idInsert','$foto_name');";
            
$result_foto mysql_query($sql_foto,$conn);
            echo 
mysql_error();
        }
        if(empty(
$errors)){
            
header("location:../page/resize_image.php?id=$idInsert");
            die();
        }
    }else{
        
header("location:../page/resize_image.php?id=$idInsert");
        die();
    } 
Qualcuno può dirmi dove sbaglio grazie