- <?php 
- session_start(); 
- $ruta_imagen=$_GET['ruta']; 
- $borrar=$_GET['foto_borrar']; 
- $barra=stripslashes($borrar); 
- if($barra!=NULL)//viene de borrar 
- { 
-   //echo $barra;//ruta a eliminar 
-   $imagenes=$_SESSION['foto']; 
-   //print_r($imagenes);//array que tenemos antes de borrar nada 
-   $i=0; 
-   $j=0; 
-   while($imagenes[$j]!=NULL) 
-   { 
-     if($imagenes[$j]!=$barra) 
-     { 
-       $imagenes_a[$i]=$imagenes[$j]; 
-       $i++; 
-     } 
-     $j++; 
-   } 
-   //print_r ($imagenes_a);//array en el que ya has eliminado lo que trae $borrar 
-   $imagenes=$imagenes_a; 
-   $_SESSION['foto']=$imagenes; 
-   $popo=$_SESSION['foto']; 
- } 
- else//viene de examinar 
- { 
-   
-   if($ruta_imagen!=NULL) 
-   { 
-     $i=0; 
-     $x=0; 
-     if($_SESSION['foto']==NULL)//si la sesión no existe, entra por primera vez 
-     { 
-       $barra=stripslashes($ruta_imagen); 
-       $size=@getimagesize($barra); 
-       if($size==true) 
-       { 
-         $rut=array(); 
-         $rutimagen[0]=$barra; 
-         $_SESSION['foto']=$rutimagen; 
-         $popo=$_SESSION['foto']; 
-         $ancho=60; 
-         $alto[0]=$size[1]/($size[0]/$ancho); 
-       } 
-       else 
-       { 
-         $error=2; 
-         $popo=$_SESSION['foto']; 
-       } 
-     } 
-     else//entra por segunda vez, la sesión existe 
-     { 
-       $imagenes=$_SESSION['foto']; 
-       $barra=stripslashes($ruta_imagen); 
-       $size=@getimagesize($barra); 
-       echo $size; 
-       if($size==true) 
-       { 
-         while($imagenes[$i]!=NULL)//si la imagen es distinta de null 
-         { 
-           if($imagenes[$i]!=$barra)//la imagen es distinta de la ruta, la metemos en sesion 
-           { 
-             $num=count($imagenes); 
-             $ancho=60; 
-             $alto[$i]=$size[1]/($size[0]/$ancho); 
-             $rutimagen=$imagenes; 
-             $rutimagen[$num]=$barra; 
-             $_SESSION['foto']=$rutimagen; 
-             $popo=$_SESSION['foto']; 
-             //break; 
-           } 
-           else//si existe la foto 
-           { 
-             $error=1; 
-             $popo=$_SESSION['foto']; 
-             break; 
-           } 
-         $i++; 
-         } 
-         $nueva_imagen=$_SESSION['foto']; 
-         while($nueva_imagen[$x]!=NULL) 
-         { 
-           $size=@getimagesize($nueva_imagen[$x]); 
-           $ancho=60; 
-           $alto[$x]=$size[1]/($size[0]/$ancho); 
-           $x++; 
-         } 
-       } 
-       else//si está dañada 
-       { 
-         $error=2; 
-         $popo=$_SESSION['foto']; 
-       }   
-     } 
-   } 
- } 
- ?> 
-   
-