Ver Mensaje Individual
  #13 (permalink)  
Antiguo 12/09/2008, 07:17
Avatar de hoberwilly
hoberwilly
 
Fecha de Ingreso: julio-2008
Ubicación: Lima - Perú
Mensajes: 769
Antigüedad: 15 años, 9 meses
Puntos: 2
De acuerdo Solucionado: Update a Imagen guardada en BD

Hasta que x fin, a veces es bueno ser terco...aqui les dejo lo realizado para quienes les sea útil o en caso contrario será del uno +. O si alguien lo realiza de otra manera...

catalogoAdmin.php
--------------------------
<?php
include('conec.php');
conectarse();
$qry=mysql_query("select * from catalogo order by id asc");
?>
...<html>...
<td><?php echo "<a href=\"editarAdmin.php?id=".$row['id']."\">Actualizar</a>" ?></td>
...

editarAdmin.php
-----------------------------
<?php
include('conec.php');
conectarse();
$registro=mysql_query("select * from catalogo where id='".$_GET['id']."'");
$row=mysql_fetch_array($registro);
?>
<html>
<head>
<title>Editar Producto</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>

<body>
<form name="frmimage" method="post" enctype="multipart/form-data" action="actualizarAdmin.php?id=<?php echo $row['id'];?>">
<table >
<tr>
<td align="center" colspan="2"><?php echo "<img src=\"verThumbnail.php?id=".$row['id']."\">"; ?><br><?php echo $row["id"]?></td>
</tr>
<tr>
<td align="right">Nuevo:</td>
<td align="center"><input type="file" size="20" id="foto" name="foto" onChange="document.imagen.src='file:///' + this.value"><br><img src="img/table_mensaje_carrito_2.jpg" name="imagen"></td>
</tr>
<tr>
<td align="right">Producto:</td>
<td><input name="producto" type="text" id="producto" size="50" maxlength="45" value="<?php echo $row["producto"]?>"></td>
</tr>
</table>
<center>
<table border=0 cellpadding=15>
<td><input type="submit" name="enviar" id="enviar" value="Guardar"></td>
</table>
</form>
</body>
</html>

actualizarAdmin.php
---------------------------
<?php
$postback = (isset($_POST["enviar"])) ? true : false;
if($postback){
error_reporting(E_ALL);
include('conec.php');
conectarse();

$mimetypes = array("image/jpeg", "image/pjpeg", "image/gif", "image/png");
$name = $_FILES["foto"]["name"];
$type = $_FILES["foto"]["type"];
$tmp_name = $_FILES["foto"]["tmp_name"];
$size = $_FILES["foto"]["size"];
if(!in_array($type, $mimetypes))
die("El archivo que subiste no es una imagen válida");
$fp = fopen($tmp_name, "rb");
$tfoto = fread($fp, filesize($tmp_name));
$tfoto = addslashes($tfoto);
fclose($fp);
@unlink($tmp_name);

$fecha = date("Y-m-d H:i:s");
$producto=$_POST['producto'];
$sql="update catalogo set foto='$tfoto', producto='$producto', fecha='$fecha' where id='".$_GET['id']."'";
mysql_query($sql) or die( "Error en $sql, error: " . mysql_error() );
header("location: catalogoAdmin.php");
return;
}
?>

Hasta otra oportunidad...bye