Foros del Web » Programando para Internet » PHP »

Subir Archivos

Estas en el tema de Subir Archivos en el foro de PHP en Foros del Web. Buenas, como estoy desesperada de ver que esto nunca funciona, por favor me podeis echar una mano y decirme que es lo que esta mal ...
  #1 (permalink)  
Antiguo 22/10/2008, 05:17
Avatar de Alafer  
Fecha de Ingreso: octubre-2008
Mensajes: 3
Antigüedad: 15 años, 5 meses
Puntos: 0
Subir Archivos

Buenas,

como estoy desesperada de ver que esto nunca funciona, por favor me podeis echar una mano y decirme que es lo que esta mal en este código: (Por cierto he mirado la FAQ pero no termino de conseguir que funcione)

<?php
ini_set('post_max_size','100M');
ini_set('upload_max_filesize','100M');
ini_set('max_execution_time','1000');
ini_set('max_input_time','1000');

if ($_POST["action"] == "upload") {

$tamano = $_FILES['archivo']['size'];
$tipo = $_FILES['archivo']['type'];
$archivo = $HTTP_POST_FILES['archivo']['name'];

$destino= "/home/http/EXTRANET/projects/RAMAN/FILES/".$_FILES['archivo']['name'];


if ($archivo != "")
{

if (move_uploaded_file($archivo,$destino))
{
echo "The file has been updated successfully: <b>".$archivo."</b>";
chmod(".$archivo",0640);
} else
{
echo "An error has ocurred during the file upload. Try again!<br>";
}
} else
{
echo "Please, select a file to upload!</b>";
}
}
;
?>


Gracias

Última edición por Alafer; 22/10/2008 a las 05:36
  #2 (permalink)  
Antiguo 22/10/2008, 05:40
Avatar de emiliodeg  
Fecha de Ingreso: septiembre-2005
Ubicación: Córdoba
Mensajes: 1.830
Antigüedad: 18 años, 7 meses
Puntos: 55
Respuesta: Subir Archivos

Código PHP:
<?php
ini_set
('post_max_size','100M');
ini_set('upload_max_filesize','100M');
ini_set('max_execution_time','1000');
ini_set('max_input_time','1000');

if (
$_POST["action"] == "upload") { 
   
    
$tamano $_FILES['archivo']['size'];
    
$tipo $_FILES['archivo']['type'];
    
$archivo $_FILES['archivo']['name'];

 
    
$destino"/home/http/EXTRANET/projects/RAMAN/FILES/".$_FILES['archivo']['name']; 


 if (
$archivo != ""
    {       
        
        if (
move_uploaded_file($_FILES['archivo']['tmp_name'],$destino)) 
        {                
           echo 
"The file has been updated successfully: <b>".$archivo."</b>";
           
chmod($destino,0640);
        } else 
        {
           echo 
"An error has ocurred during the file upload. Try again! (Tipo de error: ".$_FILES['archivo']['error'].")<br>";
        }
    } else 
    {
       echo 
"Please, select a file to upload!</b>";
    }


?>
proba con esto a ver como va
__________________
Degiovanni Emilio
developtus.com
  #3 (permalink)  
Antiguo 22/10/2008, 05:48
Avatar de Alafer  
Fecha de Ingreso: octubre-2008
Mensajes: 3
Antigüedad: 15 años, 5 meses
Puntos: 0
Respuesta: Subir Archivos

Pues parece que me sube el archivo, pero me casca en el chmod:

The file has been updated successfully: DSCN1037.JPG
Warning: chmod() [function.chmod]: No such file or directory in /home/http/EXTRANET/projects/RAMAN/Web/upload.php on line 23

Dejare el chmod en el nombre del archivo a ver si así no casca!
  #4 (permalink)  
Antiguo 22/10/2008, 06:32
Avatar de vb2005  
Fecha de Ingreso: noviembre-2005
Ubicación: Paderborn - Alemania
Mensajes: 566
Antigüedad: 18 años, 5 meses
Puntos: 24
Respuesta: Subir Archivos

el error quiere decir que la carpeta no existe, verifica la existencia de la misma
__________________
www.marcher.com.uy - Web personal
Nerd's Corner - Desarrollo de software a medida
  #5 (permalink)  
Antiguo 22/10/2008, 06:49
Avatar de Alafer  
Fecha de Ingreso: octubre-2008
Mensajes: 3
Antigüedad: 15 años, 5 meses
Puntos: 0
Respuesta: Subir Archivos

Aqui teneis la cosa funcionando por si le sirve de algo a alguien. Mil gracias! :

Código PHP:
<?php
ini_set
('post_max_size','100M');
ini_set('upload_max_filesize','100M');
ini_set('max_execution_time','100000');
ini_set('max_input_time','100000');

if (
$_POST["action"] == "upload") { 
   
    
$tamano $_FILES['archivo']['size'];
    
$tipo $_FILES['archivo']['type'];
    
$archivo $_FILES['archivo']['name'];

 
    
$destino"/home/http/EXTRANET/projects/RAMAN/FILES/".$_FILES['archivo']['name']; 


 if (
$archivo != ""
    {       
        
        if (
move_uploaded_file($_FILES['archivo']['tmp_name'],$destino)) 
        {                
           echo 
"<br><br><br><br><P CLASS=Comentario ALIGN=CENTER>The file <b>".$archivo."</b> has been uploaded successfully" ;
           
chmod("$destino",0640);
        } else 
        {
           echo 
"<br><br><br><br><P CLASS=Comentario ALIGN=CENTER>An error has ocurred during the file upload. Try again! (Error type: ".$_FILES['archivo']['error'].")<br>";
        }
    } else 
    {
       echo 
"<br><br><br><br><P CLASS=Comentario ALIGN=CENTER>Please, select a file to upload!</b>";
    }


?> 

<HTML>
<HEAD>
    <TITLE></TITLE>
    <LINK REL="stylesheet" HREF="estilo.css" TYPE="text/css">
</HEAD>

<BODY BACKGROUND="Imagenes/marte.jpg" BGPROPERTIES="fixed"> 

</BODY>
</HTML>
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 07:11.