I want to show what happened when saving an image in the database and then redirect to another page with a header, and I can not see the alert messages indicating if the image was saved. This is my code:
<?php
require 'conexion.php';
$escuela=5;
$cvealumno=13;
$archivotemp=$_FILES["archivo"]["name"];
$ruta = 'files/'.$escuela.'/'.$cvealumno.'/';
$tiempo=time();
$archivo=$ruta.$tiempo.$archivotemp;
$sql = "INSERT INTO personasfoto (escuela, cvealumno, fotocarpeta) VALUES ('$escuela', '$cvealumno', '$archivo')";
mysqli_query($conexion,$sql);
if($_FILES["archivo"]["error"]>0){
echo "Error al cargar archivo";
} else {
$permitidos = array("image/gif","image/png","image/jpg","image/jpeg","image/bmp" );
$limite_kb = 400;
if(in_array($_FILES["archivo"]["type"], $permitidos) && $_FILES["archivo"]["size"] <= $limite_kb * 1024){
if(!file_exists($ruta)){
mkdir($ruta, 0777,true);
}
if(!file_exists($archivo)){
$resultado = @move_uploaded_file($_FILES["archivo"]["tmp_name"], $archivo);
if($resultado){
//echo "Archivo Guardado";
echo '<script language="javascript">alert("Archivo Guardado");</script>';
} else {
//echo "Error al guardar archivo";
echo '<script language="javascript">alert("Error al guardar archivo");</script>';
}
} else {
//echo "Archivo ya existe";
echo '<script language="javascript">alert("Archivo ya existe");</script>';
}
} else {
//echo "Archivo no permitido o excede el tamaño";
echo '<script language="javascript">alert("Archivo no permitido o excede el tamaño");</script>';
}
}
header("location:indexfoto.php");
?>
- Thanks in advance, regards.