Ver Mensaje Individual
  #27 (permalink)  
Antiguo 17/10/2011, 17:32
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
Respuesta: borrar archivo con php

aca llamo al directorio donde estan almacenadas las imagenes y es donde esta el enlace borrar imagen

Código HTML:
Ver original
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2.   <title>Panel de moderacion</title>
  3.   <link rel="shortcut icon"
  4. href="http://hostimg.com.ar/images/favicon.png">
  5.   <link rel="stylesheet" type="text/css"
  6. href="http://hostimg.com.ar/css/moderacion/style.css">
  7. <!---CODIGO DE SEGUIMIENTO DE GOOGLE--->
  8.   <script type="text/javascript">
  9. var _gaq = _gaq || [];
  10. _gaq.push(['_setAccount', 'UA-26192364-1']);
  11. _gaq.push(['_trackPageview']);
  12. (function() {
  13. var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  14. ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  15. var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  16. })();
  17.   </script><!---FIN DEL CODIGO DE GOOGLE--->
  18. </head>
  19. <h1>
  20. <center>Moderacion</center>
  21. </h1>
  22.     <?
  23.    $opciones = "";
  24.    //definimos el directorio donde se guadan los archivos
  25.    $path = "../../imagenes/";
  26.    //abrimos el directorio
  27.    $dir = opendir($path);
  28.    //guardamos los archivos en un arreglo
  29.    $img_total=0;
  30.    while ($elemento = readdir($dir))
  31.    {
  32.    if (strlen($elemento)>3)
  33.     {
  34.     $img_array[$img_total]=$elemento;
  35.     }
  36.      
  37.     $img_total++;
  38.     }
  39.      
  40.     for ($i=0;$i<$img_total; $i++)
  41.    {
  42.    $imagen = $img_array[$i];
  43.    $num = $i+1;
  44.    $pathimagen=$path.$imagen;
  45.    if ($columna==1)
  46.    echo "<tr>";
  47.     echo "<td align='center'>";
  48.     echo"<img src='$pathimagen' title='$pathimagen' width='300' height='300' border='5'> <div id='opciones'><b>Click para </b><a href='borrar.php?path=$pathimagen'>Borrar imagen</a></br></br><b>Detalles de imagen: </b>$imagen </br></br><b>Guardada en: </b> </br> $path</div></br>";
  49.     echo "</td>";
  50.     if ($columna == $img_col)
  51.     {
  52.     $columna=1;
  53.     echo "</tr>";
  54.     }
  55.     else
  56.     {
  57.     $columna++;
  58.     }
  59.     }
  60.     ?>
  61. </form>
  62. </body>
  63. </html>

aca mas claro el enlace <a href='borrar.php?path=$pathimagen'>Borrar imagen</a>

y aca tengo el BORRAR.PHP:

Código PHP:
Ver original
  1. <?php
  2.     if (is_file($pathimage))
  3.     {
  4.       unlink($pathimage);
  5.     }
  6.     else
  7.     {
  8.       echo 'El archivo no existe: ', $pathimage;
  9.     }
  10. ?>

tengo algo mal hecho?? si me puedes corregir los errores te lo agradesco