Ver Mensaje Individual
  #1 (permalink)  
Antiguo 23/01/2010, 14:38
Yurisimo
 
Fecha de Ingreso: julio-2009
Mensajes: 111
Antigüedad: 17 años, 3 meses
Puntos: 0
La funcion getimagesize no reconoce la imagen

Hola muy buenas,

Me esta pasando un cosa que no entiendo, hace tiempo cree una videoteca, y en alta-peliculas, pues habia un formulario con insercion de imagenes las cuales las trataba en un script que me iba, ahora estoy haciendo un blog y la verdad esq ese script me va de perlas... pero resulta que en el blog no funciona..

Código PHP:
<?php
// tipos Mime que aceptamos
$TipMime = array("image/jpg", "image/jpeg", "image/pjpeg", "image/gif", "image/png", "image/x-png");


// Obtenemos la información de la imagen
$name = $_FILES['caratula']['name'];
$type = $_FILES['caratula']['type'];
$size = $_FILES['caratula']['size'];
$tmp_name = $_FILES['caratula']['tmp_name'];
$error = $_FILES['caratula']['error'];

$archivoTemp=getimagesize($_FILES['caratula']['tmp_name']);

// Verificamos si el archivo es una imagen 
if (!in_array($type, $TipMime)) {
    
// in_array: revisa si un valor existe en una matriz
    
    
$msgImagen = "El archivo $name no es válido";
    
} else {

    
$msgImagen = "La imagen $name tiene el formato válido esperado";

    
// Creamos el thumbnail según el tipo de imagen, a partir del fichero temporal
    
switch($type) {
        case 
$TipMime[0]:
            
$imagen = imagecreatefromjpeg($tmp_name);
            break;
        case 
$TipMime[1]:
            
$imagen = imagecreatefromjpeg($tmp_name);
            break;
        case 
$TipMime[2]:
            
$imagen = imagecreatefromjpeg($tmp_name);
            break;
        case 
$TipMime[3]:
            
$imagen = imagecreatefromgif($tmp_name);
            break;
        case 
$TipMime[4]:
            
$imagen = imagecreatefrompng($tmp_name);
            break;
        case 
$TipMime[5]:
            
$imagen = imagecreatefrompng($tmp_name);
            break;
    }


    
// Definimos la medida máxima...
    
$thumb_max = 150;  
    
$FotoG_max = 600; 

    
    if (
$archivoTemp[0] > $archivoTemp[1]) { // anchura > altura
    
            
            
$thumb_w = $thumb_max; // El ancho es el tamaño maximo
            
$thumb_h = round(($archivoTemp[1] / $archivoTemp[0])*$thumb_max);
            
//...de la grande
            
$FotoG_w = $FotoG_max;
            
$FotoG_h = round(($archivoTemp[1] / $archivoTemp[0])*$FotoG_max);
            
    } else { 
// Si es vertical...
            
            
            
$thumb_w = round(($archivoTemp[0] / $archivoTemp[1])*$thumb_max);
            
$thumb_h = $thumb_max;
            
//...de la grande
            
$FotoG_w = round(($archivoTemp[0] / $archivoTemp[1])*$FotoG_max);
            
$FotoG_h = $FotoG_max;
    }
    
    
    
$thumb = imagecreatetruecolor($thumb_w, $thumb_h);
    
$FotoG = imagecreatetruecolor($FotoG_w, $FotoG_h);
    
    
imagecopyresampled($thumb, $imagen, 0,0,0,0, $thumb_w, $thumb_h, imagesx($imagen), imagesy($imagen));
    
    
imagecopyresampled($FotoG, $imagen, 0,0,0,0, $FotoG_w, $FotoG_h, imagesx($imagen), imagesy($imagen));
    
    
    
imagedestroy($imagen);

    
//definimos las rutas
    
$carpetaThumbs = "../img/"; 
    
$carpetaFotoG = "../img/";

    
//damos salida a la imagen
    
switch($type) {
        case 
$TipMime[0]:
            
imagejpeg($thumb, $carpetaThumbs.'T'.$name);
            
imagejpeg($FotoG, $carpetaFotoG.$name);
            break;
        case 
$TipMime[1]:
            
imagejpeg($thumb, $carpetaThumbs.'T'.$name);
            
imagejpeg($FotoG, $carpetaFotoG.$name);
            break;
        case 
$TipMime[2]:
            
imagejpeg($thumb, $carpetaThumbs.'T'.$name);
            
imagejpeg($FotoG, $carpetaFotoG.$name);
            break;
        case 
$TipMime[3]:
            
imagegif($thumb, $carpetaThumbs.'T'.$name);
            
imagegif($FotoG, $carpetaFotoG.$name);
            break;
        case 
$TipMime[4]:
            
imagepng($thumb, $carpetaThumbs.'T'.$name);
            
imagepng($FotoG, $carpetaFotoG.$name);
            break;
        case 
$TipMime[5]:
            
imagepng($thumb, $carpetaThumbs.'T'.$name);
            
imagepng($FotoG, $carpetaFotoG.$name);
            break;
    }

    
$tumbFinal = 'img/'.'T'.$name;
    
$FotoFinal = 'img/'.$name;
    
    
imagedestroy($thumb);
    
imagedestroy($FotoG);
    @
unlink($_FILES['caratula']['tmp_name']);
}
?>
En este caso me dice que la funcion getimagesize esta vacia y lo curioso esq en la videoteca me va fenomenal...

Si quereis pongo mas informacion...
Muchas gracias