Ver Mensaje Individual
  #9 (permalink)  
Antiguo 10/11/2016, 09:40
Avatar de Jose_A
Jose_A
 
Fecha de Ingreso: mayo-2015
Ubicación: México, Sonora.
Mensajes: 180
Antigüedad: 9 años
Puntos: 0
Respuesta: Cómo visualizar una imagen subida por un usuario

Puede ser pero ya revisé los códigos y no encuentro cual es el error, no lo veo. Por ejemplo, este otro código recibe la imagen de la credencial, el proceso es prácticamente el mismo a la otra pero esta si funciona:
Código:
<?php
$target_dir = "estudiantes/";
$uploadOk = 1;
$imageFileType = pathinfo($_FILES["rutaIMGcred"]["name"],PATHINFO_EXTENSION);

// Check if image file is a actual image or fake image

    $target_file = $target_dir.$folio.".".$imageFileType;
    $check = getimagesize($_FILES["rutaIMGcred"]["tmp_name"]);
    if($check !== false) {
        //echo "File is an image - " . $check["mime"] . ".";
        $uploadOk = 1;
    } else {
        echo "File is not an image.";
        $uploadOk = 0;
    }

// Check if file already exists
if (file_exists(basename(substr($target_file,0,-4)))) {
    echo "Sorry, file already exists.";
    $uploadOk = 0;
}
// Check file size

if ($_FILES["rutaIMGcred"]["size"] > 2097152) {
    header("Location: index.php?error=2");
    echo "Sorry, your file is too large.";
    exit();
}
// 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 "Sorry, your file was not uploaded.";
    exit();
// if everything is ok, try to upload file
} else {
    if (move_uploaded_file($_FILES["rutaIMGcred"]["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."'"); 
    } else {
        echo "Lo sentimos, ocurrio un error al guardar el archivo";
    }
    }



?>

Edito:

Ya se resolvió, como dijo el compañero arriba, había una función en js que establecía la ruta de la imagen y también en php, pero se mandaba desde otro archivo que no había visto.
Gracias por responder a todos !!

Última edición por Jose_A; 10/11/2016 a las 11:38