Hola
Bueno, podrias hacer esto
Código PHP:
<?php
//conexion a la db
$link = mysql_connect("localhost", "");
mysql_select_db("tomassi", $link);
//variable imagen
$imagen = $_FILES['imagen']['name']; //name puede ser tmp_name
//sentencia Sql
if($action == "insert"){
$sql = "INSERT INTO imagenes (id,imagen)
VALUES ('1','".$imagen."')";
//guardo la imagen en la carpeta imagen
chmod($_FILES['imagen']['tmp_name'],777);
$upfile1=move_uploaded_file($_FILES['imagen']['tmp_name'], "images/".$imagen."");
$result = mysql_query($sql);
}
//conexion a la tabla imagenes
$result2 = mysql_query("SELECT * FROM imagenes", $link);
if($action =="delete"){
//eliminacion de Registro
$result3 = mysql_query("DELETE from imagenes WHERE id='$id'", $link);
header("location: prueba.php");
}
?>
Código HTML:
<form action="prueba.php" method="post" name="registro" enctype="multipart/form-data">
<table border="0" cellpadding="0" width="400">
<tr>
<td width="61%"><div align="right">Imagen:</div></td>
<td width="51%">
<input type="file" name="imagen" size="35">
<input type="hidden" name="action" value="insert">
<input type="submit" value="Ingresar" name="b1" style="width: 85px;">
</td>
</tr>
</table>
</form>
Código PHP:
<?php
while($row = mysql_fetch_array($result2))
{
$imagen =$row["imagen"];
$id =$row["id"];
?> <tr> <TD width="350" valign="top" align="center">
<?php echo "<img src=\"".$imagen."\" width=\"100\" height=\"50\" align=\"center\" border=\"1\" />"; ?>
Imagen <?php echo $row["id"] ?>
<?php echo "<a href=\"prueba.php?action=delete&id=$id\" >Eliminar</a>" ?>
<br><br> </TD> </tr>
<?php
}
?>