Ver Mensaje Individual
  #4 (permalink)  
Antiguo 06/05/2012, 16:09
Avatar de gjx2
gjx2
 
Fecha de Ingreso: agosto-2008
Ubicación: R.D
Mensajes: 1.153
Antigüedad: 15 años, 8 meses
Puntos: 139
Respuesta: [Consulta] Comprobar tipo de archivo.

Tu codigo en varios puntos tiene algunos errores, prefiero presentarte una alternativa
basada en lo que ya tienes.

Código PHP:
Ver original
  1. $my_array['type'][] = 'image/jpeg';
  2. $my_array['type'][] = 'image/png';
  3.  
  4.  
  5. if( check($my_array['type'])){
  6.  
  7. echo "existen no permitidos";
  8. }else{
  9. echo "todos son permitidos";
  10.  
  11.    
  12. }
  13.  
  14. function check($filetypes)
  15.     {    
  16.  
  17.  $types = array(
  18.         'image/jpeg',
  19.         'image/gif',
  20.         'image/png',
  21.         'image/pjpeg',
  22.         'image/x-png'
  23.   );
  24.         $error = false;
  25.         foreach ($filetypes as $file) {
  26.             if( !in_array($file, $types) ){
  27.                 $error = true;
  28.             }
  29.            
  30.         }
  31.             return $error;
  32.        
  33.        
  34.     }

Simule los campos de file con $my_array
espero que puedas interpretarlo.

Saludos.