Foros del Web » Programando para Internet » PHP »

Problema eliminar imagenes PHP

Estas en el tema de Problema eliminar imagenes PHP en el foro de PHP en Foros del Web. Hola de nuevo En la web que estoy haciendo he hecho un php para subir dos imagenes y texto, lo sube todo perfectamente, pero el ...
  #1 (permalink)  
Antiguo 21/08/2011, 04:18
 
Fecha de Ingreso: agosto-2011
Ubicación: Sevilla
Mensajes: 18
Antigüedad: 12 años, 8 meses
Puntos: 0
Problema eliminar imagenes PHP

Hola de nuevo
En la web que estoy haciendo he hecho un php para subir dos imagenes y texto, lo sube todo perfectamente, pero el problema es que puedo eliminar el texto, pero una de las imagenes no y como todavía no estoy muy puesto en esto del PHP no consigo dar con la tecla. Aquí os dejo el código para subir las imagenes (que funciona bien) y a continuación el código para eliminarlas (el que no funciona) por si me podeis orientar en donde está el fallo.

Un saludo y gracias de antemano.

ESTE ES EL FORMULARIO DE SUBIDA (Funciona correctamente)
Código PHP:
Ver original
  1. <form id='FormName' action='added.php' method='post' name='FormName' enctype='multipart/form-data'>
  2. <table width='448' border='0' cellspacing='2' cellpadding='0'>
  3. <tr>
  4.     <td width = '150'><div align='right'><label for='comp'>competición</label></div></td>
  5.     <td><input id='comp' name='comp' type='text' size='20' value='$comp' maxlength='255'></td>
  6. </tr>
  7. <tr>
  8.     <td width = '150'><div align='right'><label for='rivalpart'>Rival</label></div></td>
  9.     <td><input id='rivalpart' name='rivalpart' type='text' size='50' value='$rivalpart' maxlength='255'></td>
  10. </tr>
  11. <tr>
  12.     <td width = '150'><div align='right'><label for='fechapart'>Fecha</label></div></td>
  13.     <td><input id='fechapart' name='fechapart' type='text' size='50' value='$fechapart' maxlength='255'></td>
  14. </tr>
  15. <tr>
  16.     <td width = '150'><div align='right'><label for='horapart'>Hora</label></div></td>
  17.     <td><input id='horapart' name='horapart' type='text' size='25' value='$horapart' maxlength='255'></td>
  18. </tr>
  19. <tr>
  20.     <td width = '150'><div align='right'><label for='estadiopart'>Estadio</label></div></td>
  21.     <td><input id='estadiopart' name='estadiopart' type='text' size='50' value='$estadiopart' maxlength='255'></td>
  22. </tr>
  23. <tr>
  24.     <td width = '150'><div align='right'><label for='imaglocal'>Escudo Local(introducir nombre.extension)</label></div></td>
  25.     <td><input id='imaglocal' name='imaglocal' type='text' size='60' value='$imaglocal' maxlength='255'></td>
  26. </tr>
  27. <tr>
  28.     <td width='150'></td>
  29.     <td><input id='imaglocal' name='local' type='file' size='60'><br></td>
  30. </tr>
  31.  
  32. <tr>
  33.     <td width = '150'><div align='right'><label for='imagvisit'>Escudo Visitante(introducir nombre.extension)</label></div></td>
  34.     <td><input id='imagvisit' name='imagvisit' type='text' size='60' value='$imagvisit' maxlength='255'></td>
  35. </tr>
  36.  
  37. <tr>
  38.     <td width='150'></td>
  39.     <td><input id='imagvisit' name='visit' type='file' size='60'><br></td>
  40.     <td><br><input type='submit' name='submitButtonName' value='Aceptar'></td>
  41. </tr>
  42. </table>
  43. </form>

Y ESTE PARTE DEL PHP DE SUBIDA (funciona correctamente)
Código PHP:
Ver original
  1. include("connect.php");
  2.  
  3. $archivo_nombre= $_FILES['local']['name'];
  4. $archivo_peso= $_FILES['local']['size'];
  5. $archivo_tipo= $_FILES['local']['type'];
  6. $archivo_temporal= $_FILES['local']['tmp_name'];
  7. $archivo_nombre2= $_FILES['visit']['name'];
  8. $archivo_peso2= $_FILES['visit']['size'];
  9. $archivo_tipo2= $_FILES['visit']['type'];
  10. $archivo_temporal2= $_FILES['visit']['tmp_name'];
  11. $comp = $_POST['comp'];
  12. $rivalpart = $_POST['rivalpart'];
  13. $imaglocal = $_POST['imaglocal'];
  14. $fechapart = $_POST['fechapart'];
  15. $horapart = $_POST['horapart'];
  16. $estadiopart = $_POST['estadiopart'];
  17. $imagvisit = $_POST['imagvisit'];
  18.  
  19.  
  20. $query = "INSERT INTO siguipart (id, comp, rivalpart, imaglocal, fechapart, horapart, estadiopart, imagvisit)
  21. VALUES ('', '$comp', '$rivalpart', '$imaglocal', '$fechapart', '$horapart', '$estadiopart', '$imagvisit')";
  22. $results = mysql_query($query);
  23.  
  24. $copiado=move_uploaded_file($archivo_temporal, $archivo_nombre);
  25. $copiado=move_uploaded_file($archivo_temporal2, $archivo_nombre2);
  26.  
  27.  
  28. if ($results)
  29. {      
  30.         if($copiado==false){
  31.         print "Error imagen";
  32.         }
  33.  
  34. echo "<br>Añadido Correctamente";
  35. }
  36. }


CODIGO DE ELIMINACION (delete.php) (Elimina texto y una sóla imágen= imaglocal)
Código PHP:
Ver original
  1. $ID = $_GET['ID'];
  2. $imaglocal = $_GET['imaglocal'];?>
  3. <div align="center">
  4. <h2>Vas a borrar este cartel <br />
  5. ¿Estas seguro?</h2>
  6. <h2><a href="deleted.php?ID=<?php echo "$ID" ?>&imaglocal=<?php echo "$imaglocal" ?>&imagvisit=<?php echo "$imagvisit" ?>">Sí</a> - <a href="index.php">No</a></h2>
  7. </div>
  8. </body>
  9. </html>
  10. <?php
  11. }
  12. ?>

PARTE DEL CODIGO DE ELIMINACION (deleted.php) (Elimina texto y una sóla imágen= imaglocal)
Código PHP:
Ver original
  1. $ID = $_GET['ID'];
  2. $imaglocal = $_GET['imaglocal'];
  3. $imagvisit = $_GET['imagvisit'];
  4.  
  5. $delete = "DELETE FROM siguipart WHERE ID='$ID' ";
  6. mysql_query($delete);
  7. unlink("$imaglocal") ;
  8. unlink("$imagvisit") ;

Última edición por juanzanper; 21/08/2011 a las 04:29
  #2 (permalink)  
Antiguo 21/08/2011, 15:52
Avatar de dmm84  
Fecha de Ingreso: marzo-2011
Mensajes: 164
Antigüedad: 13 años, 1 mes
Puntos: 13
Respuesta: Problema eliminar imagenes PHP

me parece que sobran las comillas que hay en unlink
__________________
Mas vale un codigo que mil palabras

Etiquetas: html, imagenes, mysql, formulario
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 14:24.