Foros del Web » Programando para Internet » PHP »

Ayuda urgente con formulario para subir archivos

Estas en el tema de Ayuda urgente con formulario para subir archivos en el foro de PHP en Foros del Web. Hola a todos: estoy iniciandome en este mundo de la programacion en PHP y he avanzado mucho, pero estoy trabada en lo siguiente: tengo un ...
  #1 (permalink)  
Antiguo 12/04/2008, 06:02
 
Fecha de Ingreso: febrero-2004
Mensajes: 47
Antigüedad: 20 años, 2 meses
Puntos: 0
Ayuda urgente con formulario para subir archivos

Hola a todos:
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&aacute;genes</td>
<td width="441" class="Estilo2">&nbsp;</td>
<td width="184" class="Estilo2">&nbsp;</td>
</tr>
<tr class="Estilo2">
<td>&nbsp;</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'] <>''){ 
[HTML]<a href="archivos/
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>&nbsp;</td>
<
td>&nbsp;</td>
<
td>&nbsp;</td>
</
tr>
<
tr class="Estilo2">
<
td>&nbsp;</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>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr class="Estilo2">
<td>&nbsp;</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="
[/PHP] echo $row_Recordset1['foto3']; [/PHP]
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>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><span class="Estilo2">
<input type='submit' value='Actualizar datos' />
</span></td>
<td>&nbsp;</td>
<td>&nbsp;</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&aacute;genes</td>
<td width="441" class="Estilo2">&nbsp;</td>
<td width="184" class="Estilo2">&nbsp;</td>
</tr>
<tr class="Estilo2">
<td>&nbsp;</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>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr class="Estilo2">
<td>&nbsp;</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>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr class="Estilo2">
<td>&nbsp;</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>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><span class="Estilo2">
<input type='submit' value='Actualizar datos' />
</span></td>
<td>&nbsp;</td>
<td>&nbsp;</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>

Última edición por pcmac; 12/04/2008 a las 12:34 Razón: Dar colores al codigo fuente como me lo indicaron
  #2 (permalink)  
Antiguo 12/04/2008, 09:41
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Re: Ayuda urgente con formulario para subir archivos

el codigo ke pones resulta no relevante, necesitamos ver al codigo en si del PHP y no del HTML

¿si me explico?

el uniko PHP encontrado aki, es solo el resultante de las consultas. vaya, necesitamos ver el codigo con el ke haces las consultas al MySQL
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 15:31.