Ver Mensaje Individual
  #6 (permalink)  
Antiguo 14/02/2007, 15:43
Avatar de lusam
lusam
 
Fecha de Ingreso: enero-2007
Ubicación: Panamá
Mensajes: 56
Antigüedad: 17 años, 3 meses
Puntos: 0
Re: Subir archivos a la web

Saludos,

Debes crear un directorio a donde quieres subir el archivo y listo, aquí t va el script corregido.

Luz

Código PHP:
<?php
/* Prueba para subir archivos a una carpeta del servidor*/

if (isset($_POST['Enviar']))
{
    
//tomo el valor de un elemento de tipo texto del formulario
    
$cadenatexto $_POST["cadenatexto"];
    echo 
"Escribió en el campo de texto: " $cadenatexto "<br><br>";

    
//datos del arhivo
    
$nombre_archivo $HTTP_POST_FILES['userfile']['name'];
    
$directorio 'xxx/'// pon al xxx el nombre de tu carpeta a donde lo vas a mover
     
if (move_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'],$directorio "/" $nombre_archivo)) 
    {
       echo 
"El archivo ha sido cargado correctamente.";
    }else{
       echo 
"Ocurrió algún error al subir el fichero. No pudo guardarse.";
    }
}
?>

<html>
<head>
<title>Documento sin t&iacute;tulo</title>
</head>

<body>
<form action="subirArchivo2.php" method="post" enctype="multipart/form-data">
    <b>Campo de tipo texto:</b>
    <br>
    <input type="text" name="cadenatexto" size="20" maxlength="100">
    <input type="hidden" name="MAX_FILE_SIZE" value="100000">
    <br>
    <br>
    <b>Enviar un nuevo archivo: </b>
    <br>
    <input name="userfile" type="file">
    <br>
    <input type="submit" value="Enviar" name="Enviar">
</form>
</body>
</html>