Foros del Web » Programando para Internet » PHP »

Problema con subida de archivos

Estas en el tema de Problema con subida de archivos en el foro de PHP en Foros del Web. En la parte de PHP tengo esto para almacenar cada imagen, en este caso este codigo es para almacenar una. Código PHP: if( $image_file1 ){ ...
  #1 (permalink)  
Antiguo 05/04/2006, 12:59
 
Fecha de Ingreso: febrero-2005
Mensajes: 97
Antigüedad: 19 años, 2 meses
Puntos: 0
Problema con subida de archivos

En la parte de PHP tengo esto para almacenar cada imagen, en este caso este codigo es para almacenar una.

Código PHP:
if($image_file1){
                
                        if (
is_uploaded_file($image_file1)) {
                        
move_uploaded_file($image_file1$DOCUMENT_ROOT "/a/img/$sec/" $image_file1_name ".jpg"); 
                        }
                    } 
Y en el HTML tengo un formulario que una vez que se envia(submit), pasa las variables a otro archivo de php que las almacena en un DB. Ahora bien, en el mismo formulario tengo dos campos type file, para subir las imagenes tambien cuando se envie el formulario. Lo que tengo no me esta funcionando, y las variables me las almacena hasta llegar a los campos de file donde deja de almacenar las vars. Tengo especificado el enctype en la etiqueta form y los campos para subir los archivos estan definidos por

Código HTML:
<input type="file" id="image_file1"*name="image_file1"> 
Apreciaria muchisimo cualquier tipo de ayuda.
__________________

www.bre4k.com
motion graphics

  #2 (permalink)  
Antiguo 05/04/2006, 13:17
Avatar de mauled  
Fecha de Ingreso: marzo-2005
Ubicación: Cd. de México.
Mensajes: 3.001
Antigüedad: 19 años, 1 mes
Puntos: 33
Te sugiero que te des una vuelta por las faqs del foro.
  #3 (permalink)  
Antiguo 05/04/2006, 13:49
 
Fecha de Ingreso: febrero-2005
Mensajes: 97
Antigüedad: 19 años, 2 meses
Puntos: 0
Gracias Mauled por tu sugerencia. Ya me habia pasado por ahi. Gracias de todas maneras ;P.. Creo que el error que tengo es mas de depuracion pero no logro verlo aun.
__________________

www.bre4k.com
motion graphics

  #4 (permalink)  
Antiguo 05/04/2006, 15:55
 
Fecha de Ingreso: febrero-2005
Mensajes: 97
Antigüedad: 19 años, 2 meses
Puntos: 0
Busqueda Codigo completo

Ok bueno coloco el codigo completo para evitar confusion. Dreamweaver =)

Código PHP:
<?

                
if($image_file1){
                
                if (
is_uploaded_file($image_file1)) {
                
                    
move_uploaded_file($image_file1$DOCUMENT_ROOT "/a/img/$sec/" $image_file1_name ".jpg"); 
                    
                    }
                    }
                    
                
                if(
$image_file2){
    
                if (
is_uploaded_file($image_file2)) {
                
                    
//if (!(is_dir($DOCUMENT_ROOT . "/img/$sec/" . $id))) {
                    //    mkdir ($DOCUMENT_ROOT . "/img/$sec/" . $id, 0777);
                    //}    
    
                    
move_uploaded_file($image_file2$DOCUMENT_ROOT "/a/img/$sec/" $image_file2_name ".jpg"); 
                    
                    }                
                    }
                

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Formulario para Usuario <? echo $varUser ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.style1 {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    color: #333333;
}
.style2 {
    color: #999999;
    font-size: 9px;
}
-->
</style>

<?
$query
=mysql_query("SELECT * FROM Users WHERE Username='$varUser'",$db);

while(
$row mysql_fetch_array($query)) {
$sec$row[Permisiologia];


$varPic1 htmlspecialchars($varPic1);
$varPic2 htmlspecialchars($varPic2);
$varText nl2br($varText);


        
?>
        <body>
        <form action="actualizar.php?sec=<? echo $sec?>" method="post" name="form2" class="style1" enctype="multipart/form-data">
        <table width="708" border="0">
          <tr align="left" valign="top">
            <td colspan="3" class="style1">Formulario para insertar nuevo registro de <? echo $sec?> </td>
          </tr>
          <tr align="left" valign="top" bgcolor="#FFCC33">
            <td colspan="3">&nbsp;</td>
          </tr>
          <tr align="left" valign="top">
            <td width="97">Titulo</td>
            <td width="451"><input name="varTitulo" type="text" size="50" maxlength="50"></td>
            <td width="146" class="style2">ej. Titulo de tema </td>
          </tr>
          <tr align="left" valign="top">
            <td>Fecha</td>
            <td><input name="varFecha" type="text" value="<?php  echo date("y-m-d"); ?>" size="25"></td>
            <td class="style2">ej. 2006-12-31</td>
          </tr>
          <tr align="left" valign="top">
            <td>Autor</td>
            <td><input name="varUser" type="text" value="<? echo $varUser?>" size="25"></td>
            <td class="style2">&nbsp;</td>
          </tr>
          <tr align="left" valign="top">
            <td>Titulo Resumen </td>
            <td><input name="varTituloResumen" type="text" size="50"></td>
            <td class="style2">ej. Este art&iacute;culo trata de x </td>
          </tr>
          <tr align="left" valign="top">
            <td height="84">Texto</td>
            <td><span class="style2">
              <textarea name="varText" cols="50"></textarea>
            </span></td>
            <td class="style2">&nbsp;</td>
          </tr>
          <tr align="left" valign="top">
            <td height="31">Pic1</td>
            <td><span class="style2">
              <input name="image_file1" type="file">
            </span>
            </td>
            <td class="style2">&nbsp;</td>
          </tr>
          <tr align="left" valign="top">
            <td>Pic2</td>
            <td><span class="style2">
            <input name="image_file2" type="file">
            </span></td>
            <td class="style2">Contenido entero del art&iacute;culo</td>
          </tr>
          <tr align="left" valign="top">
            <td height="39">&nbsp;</td>
            <td>&nbsp;</td>
            <td><input type="submit" name="Submit" value="Submit"></td>
          </tr>
        </table>
        </form>
        </body>
</html>
__________________

www.bre4k.com
motion graphics

  #5 (permalink)  
Antiguo 05/04/2006, 16:01
Avatar de Mickel  
Fecha de Ingreso: mayo-2002
Ubicación: Lima, Peru
Mensajes: 4.619
Antigüedad: 21 años, 11 meses
Puntos: 7
yo haria primero un echo a $image_file1 para ver si esta reconociendo el archivo...
__________________
No tengo firma ahora... :(
  #6 (permalink)  
Antiguo 05/04/2006, 17:26
 
Fecha de Ingreso: febrero-2005
Mensajes: 97
Antigüedad: 19 años, 2 meses
Puntos: 0
En tal caso... echo $image_file1_name para que saque el nombre, no?
__________________

www.bre4k.com
motion graphics

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 23:04.