<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Refresh" content="10;url=./">
</head>
<body>
<?php
$target_dir = "archivos/";
$uploadOk = 1;
$imageFileType = pathinfo($_FILES["fileToUpload"]["name"],PATHINFO_EXTENSION);
// Check if image file is a actual image or fake image
if(isset($_POST["submit"])) {
$folio=$_POST["folio"];
include 'conexion.php';
$tabla=$mysqli->query("select folio from asistente where folio='".$folio."'");
if ($tabla->num_rows > 0) {
$target_file = $target_dir.$folio.".".$imageFileType;
$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
if($check !== false) {
//echo "File is an image - " . $check["mime"] . ".";
$uploadOk = 1;
} else {
echo "<br>Lo sentimos, el archivo enviado no es una imagen.<br>
Favor de crear comprobante en una imagen y enviarlo después.<br>";
$uploadOk = 0;
}
// Check if file already exists
if (file_exists(basename(substr($target_file,0,-4)))) {
echo "<br>Lo sentimos, el archivo ya ha sido enviado.<br>";
$uploadOk = 0;
}
// Check file size
if ($_FILES["fileToUpload"]["size"] > 2097152) {
header("Location: index.php?error=2");
//echo "Sorry, your file is too large.";
}
// Allow certain file formats
/*if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
&& $imageFileType != "gif" ) {
echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
$uploadOk = 0;
}*/
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
echo "<br>Tu archivo NO ha sido almacenado. Favor de intentar
después. <br>";
// if everything is ok, try to upload file
} else {
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
//echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
//echo basename($target_file)."<br>";
//echo basename(substr($target_file,0,-4).".*");
$target_file=$mysqli->real_escape_string($target_file);
$tabla=$mysqli->query("update asistente set rutaImg='".$target_file."' where folio='".$folio."'");
echo "<br>Gracias por enviar tu comprobante <br>";
} else {
echo "<br>Lo sentimos, ocurrio un error al guardar el archivo<br>";
}
}
}
}
echo "<br>El sitio te lleva a la página principal en 10 segundos.
<br>Si no te redirige, puedes <a href=\"./\">hacer click aquí</a>";
?>
</body>
</html>