PHP - validar imagen antes de subir a bd

 
Vista:

validar imagen antes de subir a bd

Publicado por Zaida (9 intervenciones) el 11/07/2007 14:35:36
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:

CODE
<?php
session_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
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder