Ver Mensaje Individual
  #7 (permalink)  
Antiguo 17/10/2011, 00:59
Avatar de alex_dh
alex_dh
 
Fecha de Ingreso: septiembre-2011
Ubicación: Kreuzberg
Mensajes: 235
Antigüedad: 12 años, 7 meses
Puntos: 14
borrar archivo con php

hola tengo este codigo con el que muestro la galeria de imagenes subidas.. y le agregue un enlace a "BORRAR.PHP" y quiero saber si esta bien... en la galeria tengo esto:

Código PHP:
Ver original
  1. <?
  2. $opciones = "";
  3. //definimos el directorio donde se guadan los archivos
  4. $path = "../../imagenes/";
  5. //abrimos el directorio
  6. $dir = opendir($path);
  7. //guardamos los archivos en un arreglo
  8. $img_total=0;
  9. while ($elemento = readdir($dir))
  10. {
  11. if (strlen($elemento)>3)
  12. {
  13. $img_array[$img_total]=$elemento;
  14. }
  15.  
  16. $img_total++;
  17. }
  18.  
  19. for ($i=0;$i<$img_total; $i++)
  20. {
  21. $imagen = $img_array[$i];
  22. $num = $i+1;
  23. $pathimagen=$path.$imagen;
  24. if ($columna==1)
  25. echo "<tr>";
  26. echo "<td align='center'>";
  27. echo"<img src='$pathimagen' title='$pathimagen' width='300' height='300' border='5'> <div id='opciones'><b>Click para </b><a href='borrar.php'>Borrar imagen</a></br></br><b>Detalles de imagen: </b>$imagen </br></br><b>Guardada en: </b> </br> $path</div></br>";
  28. echo "</td>";
  29. if ($columna == $img_col)
  30. {
  31. $columna=1;
  32. echo "</tr>";
  33. }
  34. else
  35. {
  36. $columna++;
  37. }
  38. }
  39. ?>

como (creo) que notaran el enlace esta en:

Código PHP:
Ver original
  1. echo"<img src='$pathimagen' title='$pathimagen' width='300' height='300' border='5'> <div id='opciones'><b>Click para </b><a href='borrar.php'>Borrar imagen</a></br></br><b>Detalles de imagen: </b>$imagen </br></br><b>Guardada en: </b> </br> $path</div></br>";

esto se dirige al archivo BORRAR.PHP

Código PHP:
Ver original
  1. <?php
  2. $fh = fopen('$pathimage', 'a');
  3. fwrite($fh, '');
  4. fclose($fh);
  5.  
  6. unlink('$pathimage');
  7. ?>

dicen que esta bien eso?? o tengo que arreglar y/o incluir otra cosa mas para que se borre la imagen al apretar ese enlace....


gracias por todo...