Programación Web y Scripting > PHP
Mostrar Imagenes Antes De Subir A La Bd
zaida20:
duda resuelta!!! ;)
De nuevo mil gracias por tu ayuda F_Tanori!!!!
Saludos!!!! :hola:
zaida20:
Hola:
tengo otra duda más, necesito que antes de mostrarme la imagen que voy a subir a la base de datos me valide si está dañada o no, es decir, que se pueda visualizar la imagen sin problemas.
¿Cómo puedo hacerlo?
El código que tengo es éste:
--- Código: Text ---<?phpsession_start();$ruta_imagen=$_GET['ruta'];if($ruta_imagen!=NULL){if($_SESSION['foto']==NULL){ $rut=array(); $rutimagen[0]=$ruta_imagen; $_SESSION['foto']=$rutimagen; $popo=$_SESSION['foto'];}else{ $foto=$_SESSION['foto']; $num=count($foto); $rutimagen=$_SESSION['foto']; $rutimagen[$num]=$ruta_imagen; $_SESSION['foto']=$rutimagen; $popo=$_SESSION['foto'];} }?><html> <table width="265" height="80" border="0" cellpadding="0" cellspacing="0"> <?php $i=0; while($popo[$i]!=NULL) { $size=getimagesize($popo[$i]); $ancho[$i]=(int) ($size [0]* 0.5); $alto[$i] =(int) ($size [1]* 0.5); ?> <tr> <td><img src="<?php echo $popo[$i]; ?>" width="<?php echo $ancho[$i]; ?>" height="<?php echo $ancho[$i]; ?>"></td> </tr> <tr> <td height="1" bgcolor="#CCCCCC"><img src="../img/transparente.gif" width="50" height="1"></td> </tr> <?php $i++; } ?> </table></html>
Muchisimas gracias
Saludos :hola:
Altareum:
Pues, ya lo estás haciendo-.... La función getimagesize verifica que el archivo no esté corrupto:
--- Citar ---Si no es posible acceder a la imagen nombre_archivo, o si no es una imagen válida, getimagesize() devolverá FALSE y generará un error de nivel E_WARNING.
--- Fin de la cita ---
Por lo que deberías poner:
if( $size=getimagesize($popo[$i]) )
Altareum.
zaida20:
Muchas gracias, lo probaré mañana en el trabajo.
Saludos!!! :hola:
zaida20:
Perfecto Altareum!!! :bravo:
Gracias por tu ayuda!!
Saludos!! :hola:
Navegación
[#] Página Siguiente
[*] Página Anterior
Ir a la versión completa