estoy iniciandome en este mundo de la programacion en PHP y he avanzado mucho, pero estoy trabada en lo siguiente:
tengo un formulariom para subir ficheros y guardar su nombre en una base de datos (BD). primero leo si existe un nombre de fichero asignado a un campo en la BD, si existe me muestra el nombre y la foto correspondiente.
ahora bien, yo tengo tres campos para guardar los nombres de tres ficheros que se pueden subir.
si ya he subido un fichero y despues (en otro momento) quiero subir otro fichero pues me quedan dos posibilidades mas.
resulta que como no escribi nada en el primer campo del formulario de fichero pues ya tiene uno asignado en la BD, cuando le doy al boton de subir los archivos, resulta que me borra de la BD el nombre del fichero que habia en el primer campo y me sube y guarda los dos restantes, me entienden?
no se si seria conveniente poder mostrar las imagenes si ya se habian subido con anterioridad y poner la opcion de borrarlos y que tampoco aparezca en este caso el cuadro de texto con el input.
aqui les envio el codigo completo del formulario a ver si me ayudan con ese problemita.
saludos a todos
PCMAC
Código HTML:
<form action="
Código PHP:
echo $editFormAction;
Código HTML:
" method='POST' enctype="multipart/form-data" name='formulario' id='formulario'><br /> <br /> <table width="779" border="0"> <tr class="Estilo2"> <td width="140">Insertar Imágenes</td> <td width="441" class="Estilo2"> </td> <td width="184" class="Estilo2"> </td> </tr> <tr class="Estilo2"> <td> </td> <td>Fichero actual: <input name="foto1" type="text"id="foto1" value="
Código PHP:
if (isset($_POST['foto1'])) {
echo htmlentities($_POST['foto1']);
} else {
echo htmlentities($row_Recordset1['foto1']);}
Código HTML:
" size="37"/>
<br />
Nuevo fichero:
<input name="foto1" type="file" id="foto1" value="
Código PHP:
echo $row_Recordset1['foto1'];
Código HTML:
" /></td> <td>
Código PHP:
if ($row_Recordset1['foto1'] <>''){
Código PHP:
echo $row_Recordset1['foto1'];
Código HTML:
" target="_blank"> <img src="archivos/
Código PHP:
echo $row_Recordset1['foto1'];
Código HTML:
" width="100" height="100" /></a>
Código PHP:
} [PHP] [HTML]
</td>
</tr>
<tr class="Estilo2">
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr class="Estilo2">
<td> </td>
<td>Fichero actual:
<input name="foto2" type="text"id="foto2" value="[/HTML][PHP] if (isset($_POST['foto2'])) {
echo htmlentities($_POST['foto2']);
} else {
echo htmlentities($row_Recordset1['foto2']);}
Código HTML:
" size="37"/>
<br />
Nuevo fichero:
<input name="foto2" type="file" id="foto2" value="
Código PHP:
echo $row_Recordset1['foto2'];
Código HTML:
" /></td> <td>
Código PHP:
if ($row_Recordset1['foto2'] <>''){
Código HTML:
<a href="archivos/
Código PHP:
echo $row_Recordset1['foto2'];
Código HTML:
" target="_blank"> <img src="archivos/
Código PHP:
echo $row_Recordset1['foto2'];
Código HTML:
" width="100" height="100" /></a>
Código PHP:
}
Código HTML:
</td> </tr> <tr class="Estilo2"> <td> </td> <td> </td> <td> </td> </tr> <tr class="Estilo2"> <td> </td> <td>Fichero actual: <input name="foto4" type="text"id="foto4" value="
Código PHP:
if (isset($_POST['foto3'])) {
echo htmlentities($_POST['foto3']);
} else {
echo htmlentities($row_Recordset1['foto3']);}
Código HTML:
" size="37"/>
<br />
Nuevo fichero:
<input name="foto3" type="file" id="foto3" value="
Código HTML:
" /></td> <td>
Código PHP:
if ($row_Recordset1['foto3'] <>''){
Código HTML:
<a href="archivos/
Código PHP:
echo $row_Recordset1['foto3'];
Código HTML:
" target="_blank"> <img src="archivos/
Código PHP:
echo $row_Recordset1['foto3'];
Código HTML:
" width="100" height="100" /></a>
Código PHP:
}
Código HTML:
</td> </tr> <tr class="Estilo2"> <td> </td> <td> </td> <td> </td> </tr> <tr> <td><span class="Estilo2"> <input type='submit' value='Actualizar datos' /> </span></td> <td> </td> <td> </td> </tr> </table> <br /> <a href="panel_control.php">Volver al Panel de Control</a> <input name="id" type="hidden" id="id" value="
Código PHP:
echo $row_Recordset1['id'];
Código HTML:
" /> <input type="hidden" name="MM_update" value="formulario" /> </form>
El codigo sin dar colores es el siguiente: lo pueden copiar y pegar en Dreamweaver y probarlo.
<form action="<?php echo $editFormAction; ?>" method='POST' enctype="multipart/form-data" name='formulario' id='formulario'><br />
<br />
<table width="779" border="0">
<tr class="Estilo2">
<td width="140">Insertar Imágenes</td>
<td width="441" class="Estilo2"> </td>
<td width="184" class="Estilo2"> </td>
</tr>
<tr class="Estilo2">
<td> </td>
<td>Fichero actual:
<input name="foto1" type="text"id="foto1" value="<?php if (isset($_POST['foto1'])) {
echo htmlentities($_POST['foto1']);
} else {
echo htmlentities($row_Recordset1['foto1']);}
?>" size="37"/>
<br />
Nuevo fichero:
<input name="foto1" type="file" id="foto1" value="<?php echo $row_Recordset1['foto1']; ?>" /></td>
<td>
<?php if ($row_Recordset1['foto1'] <>''){?>
<a href="archivos/<?php echo $row_Recordset1['foto1']; ?>" target="_blank"> <img src="archivos/<?php echo $row_Recordset1['foto1']; ?>" width="100" height="100" /></a>
<?php } ?>
</td>
</tr>
<tr class="Estilo2">
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr class="Estilo2">
<td> </td>
<td>Fichero actual:
<input name="foto2" type="text"id="foto2" value="<?php if (isset($_POST['foto2'])) {
echo htmlentities($_POST['foto2']);
} else {
echo htmlentities($row_Recordset1['foto2']);}
?>" size="37"/>
<br />
Nuevo fichero:
<input name="foto2" type="file" id="foto2" value="<?php echo $row_Recordset1['foto2']; ?>" /></td>
<td>
<?php if ($row_Recordset1['foto2'] <>''){?>
<a href="archivos/<?php echo $row_Recordset1['foto2']; ?>" target="_blank"> <img src="archivos/<?php echo $row_Recordset1['foto2']; ?>" width="100" height="100" /></a>
<?php } ?>
</td>
</tr>
<tr class="Estilo2">
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr class="Estilo2">
<td> </td>
<td>Fichero actual:
<input name="foto4" type="text"id="foto4" value="<?php if (isset($_POST['foto3'])) {
echo htmlentities($_POST['foto3']);
} else {
echo htmlentities($row_Recordset1['foto3']);}
?>" size="37"/>
<br />
Nuevo fichero:
<input name="foto3" type="file" id="foto3" value="<?php echo $row_Recordset1['foto3']; ?>" /></td>
<td>
<?php if ($row_Recordset1['foto3'] <>''){?>
<a href="archivos/<?php echo $row_Recordset1['foto3']; ?>" target="_blank"> <img src="archivos/<?php echo $row_Recordset1['foto3']; ?>" width="100" height="100" /></a>
<?php } ?>
</td>
</tr>
<tr class="Estilo2">
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td><span class="Estilo2">
<input type='submit' value='Actualizar datos' />
</span></td>
<td> </td>
<td> </td>
</tr>
</table>
<br />
<a href="panel_control.php">Volver al Panel de Control</a>
<input name="id" type="hidden" id="id" value="<?php echo $row_Recordset1['id']; ?>" />
<input type="hidden" name="MM_update" value="formulario" />
</form>