Ver Mensaje Individual
  #1 (permalink)  
Antiguo 27/08/2020, 13:31
karenlorenadg
 
Fecha de Ingreso: octubre-2008
Ubicación: Colombia
Mensajes: 448
Antigüedad: 15 años, 6 meses
Puntos: 2
Verificar tipo de Archivo

Hola amigoos, tengo un sistema para subir imagenes, al parecer la sintaxis no deja subir sino es archivo tipo imagen jpg, png o gif, pero en la practica no es asi, veo que me estan subiendo archivos en pdf, y no quiero que suban este tipo de archivos. Ayudemne que debo agregar para limitar esto?

Código PHP:
<?php
include("logica/conexion.php");

$target_dir "./img_certific/";
$target_file $target_dir date('Ymd-His') . '_' basename($_FILES["comprobante"]["name"]);
$uploadOk 1;
$imageFileType pathinfo($target_file,PATHINFO_EXTENSION);
// Check if image file is a actual image or fake image
if(isset($_POST["submit"])) {
    
$check getimagesize($_FILES["comprobante"]["tmp_name"]);
    if(
$check !== false) {
        
//echo "File is an image - " . $check["mime"] . ".";
        
$uploadOk 1;
    } else {
        
//echo "File is not an image.";
        
$uploadOk 0;
    }
}



if(
$imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
&& $imageFileType != "gif" ) {
    
//echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
    
$uploadOk 0;
}

// Check file size


 
if (move_uploaded_file($_FILES["comprobante"]["tmp_name"], $target_file)) {
        
//echo "El archivo ". basename( $_FILES["foto_1"]["name"]). " ha sido cargado.";
    
} else {
        
//echo "Sorry, there was an error uploading your file.";
    
}

$sql="insert into table_certificados values 
(null,'"
.$_POST["nombres"]."','".$_POST["email"]."','".$_POST["grado"]."','".$_POST["ano_curso"]."','".$_POST["grado2"]."','".$_POST["ano_curso2"]."','".$_POST["grado3"]."','".$_POST["ano_curso3"]."','".$_POST["grado4"]."','".$_POST["ano_curso4"]."','".$_POST["grado5"]."','".$_POST["ano_curso5"]."','".$_POST["grado6"]."','".$_POST["ano_curso6"]."','".$target_file."','".$_POST["mensaje"]."','".$_POST["estado"]."',now())
"
;

$res mysqli_query($conectar$sql);
//$res=mysqli_query($sql,$conexion);

echo "<script type=''>
    
    window.location='confirmar_envio.php';
</script>"
;

?>
__________________
Desarrollo de Aplicaciones de Escritorio, Sitios Web, Audio y Video en SISGUS