Ver Mensaje Individual
  #1 (permalink)  
Antiguo 02/02/2005, 05:20
Maru77
 
Fecha de Ingreso: agosto-2003
Mensajes: 524
Antigüedad: 20 años, 8 meses
Puntos: 5
Actualizar una imagen

En un registro a modificar además de visualizar la imagen, quiero también poder modificarla, esto último no se cómo hacerlo, parece que el "update" no reconoce la variable de la imagen o quizás haya algo que estoy haciendo mal. No da ningún error simplemente que la imagen no se actualiza.

Espero puedan ayudarme, muchas gracias!
Maru.-

actualizar.php

<?php error_reporting(E_ALL); ?>

<?php
foreach($HTTP_POST_VARS as $varname => $value)
$formVars[$varname]=$value;

$Host = "localhost";
$User = "";
$Password = "";
$Base = "baseprod";
$Tabla = "productos";

$Link = mysql_connect ($Host, $User, $Password) or die("Error vp conexion ".mysql_error());
mysql_select_db($Base, $Link) or die("Error select db ".mysql_error());

$query="SELECT * FROM productos WHERE producto= \"".$formVars["producto"]."\"";

$result=mysql_query($query) or die("error query $Query ". mysql_error());
$row=mysql_fetch_array($result);

$formVars = array();
$formVars["codigo"]=$row["codigo"];
$formVars["producto"]=$row["producto"];
$formVars["descripcion"]=$row["descripcion"];
$formVars["precio"]=$row["precio"];
$formVars["id"]=$row["id"]; // ESTA SERIA LA IMAGEN
?>
<html>
<head>

</head>
<body bgcolor="white">
<form enctype="multipart/form-data" method="post" action="postactualizar.php">

<table>
<col span="1" align="right">
<tr>
<td><font color="blue">Código:</font></td>
<td><input type="text" name="codigo"
value="<? echo $formVars["codigo"]; ?>" size=30></td>
</tr>
<tr>
<td><font color="blue">Producto:</font></td>
<td><input type="text" name="producto"
value="<? echo $formVars["producto"]; ?>" size=30></td>
</tr>
<tr>
<td><font color="blue">Descripción:</font></td>
<td><input type="text" name="descripcion"
value="<? echo $formVars["descripcion"]; ?>" size=30></td>
</tr>
<tr>
<td><font color="blue">Precio:</font></td>
<td><input type="text" name="precio"
value="<? echo $formVars["precio"]; ?>" size=30></td>
</tr>

<tr>
<td><input type='file' name='archivo'></td> // ACA SE INGRESARIA LA IMAGEN A ACTUALIZAR</tr>

<tr>
<td><input type="submit" value="Actualizar"></td>

</tr>
</table>


// VISUALIZA LA IMAGEN EXISTENTE - NO SE SI ES LA MEJOR FORMA PERO ES DE LA UNICA MANERA QUE LO LOGRE

<?
echo "<td><font color='blue'>Imagen:</td> \n";
echo "<td bordercolor='#ffffff'><img src=\"imagen.php?id=".$formVars['id']."\"> "."</td>";
?>


</form>
</body>
</html>


postactualizar.php

<html>
<head>

</head>

<?php error_reporting(E_ALL); ?>

<?php
foreach($HTTP_POST_VARS as $varname => $value)
$formVars[$varname]=$value;

$Host = "localhost";
$User = "";
$Password = "";
$Base = "baseprod";
$Tabla = "productos";

$Link = mysql_connect ($Host, $User, $Password) or die("Error vp conexion ".mysql_error());
mysql_select_db($Base, $Link) or die("Error select db ".mysql_error());


$query = "UPDATE productos set codigo='$codigo', producto='$producto', descripcion='$descripcion', precio='$precio' WHERE producto='$producto'";

// AGREGANDOLE LAS VARIABLES DE LA IMAGEN TAMPOCO LA ACTUALIZA archivo_binario= '$archivo_binario', archivo_nombre= '$archivo_nombre', archivo_peso= '$archivo_peso',
archivo_tipo= '$archivo_tipo'

mysql_query($query);

?>
</body>
</html>