I have a code that searches for me through the PLACA identifier some data, inside that data there is an image, I show it by means of the temporary one. up there all right, the problem comes when I want to update the data, sometimes I want to update the image and not others, but if I update any data the image is deleted, and I do not know how to store it. try naively putting <input type="file" name="imagen1" id="imagen1" value="<?php echo $fila[$ruta1]; ?>">
, but obviously it did not work. PDT: I know that the code is basic and little, but I did not want to extend it much, I also know that I should not use the mysql library, but that is what it is for now.
PHP
if(is_uploaded_file($_FILES["imagen6"]["tmp_name"])) {
$ruta6= "FOTOS/".'_'.substr(sha1(rand(1,999)),0,-30).$_FILES["imagen6"]["name"];
move_uploaded_file($_FILES["imagen6"]["tmp_name"], $ruta6);
}
$updateSQL = sprintf("UPDATE huawei_parque_automotor SET PLACA=%s, imagen1=%s WHERE id=%s",
GetSQLValueString($_POST['PLACA'], "text"),
GetSQLValueString($ruta1, "text"),
GetSQLValueString($_POST['id'], "int"));
HTML
<?php
$rst_informe = mysql_query("SELECT * FROM huawei_parque_automotor WHERE PLACA = '$PLACA'", $conexion);
$num_registros = mysql_num_rows($rst_informe);
?>
<?php
while ($fila=mysql_fetch_array($rst_informe))
{
?>
<td><input value="<?php echo $fila['PLACA']; ?>" type="text" name="PLACA" id="PLACA" /></td>
<td><img src="<?php echo $fila['imagen1']; ?>" alt="" width="125" height="125"/></td>
<?php
}
?>
<input type="hidden" name="MM_update" value="form1" />
<input type="hidden" name="id" value="<?php echo $fila['id']; ?>" />
<input type="submit" name="Actualizar" id="Actualizar" value="Actualizar"/>