Un saludo.
Este es el formulario:
Código:
Y este el upload.php:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Upload</title> </head> <body> <form action="./upload.php" method="post" enctype="multipart/form-data"> <div> <input type="file" name="prueba"/> <input type="submit" value="upload"/> </div> </form> </body> </html>
Código:
<?php
$nombre_archivo = $HTTP_POST_FILES['userfile']['name'];
$tipo_archivo = $HTTP_POST_FILES['userfile']['type'];
$tamano_archivo = $HTTP_POST_FILES['userfile']['size'];
$nombre_dir = "/uploadsimple";
$nombre_ruta = $nombre_archivo . $nombre_dir ;
if(isset($enviar)){
$nombre_archivo = $HTTP_POST_FILES['userfile']['name'];
$tipo_archivo = $HTTP_POST_FILES['userfile']['type'];
$tamano_archivo = $HTTP_POST_FILES['userfile']['size'];
$nombre_dir = "/uploadsimple";
$nombre_ruta = $nombre_dir. "/uploadsimple" .$nombre_archivo ;
if (move_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'], $nombre_ruta))
echo "El archivo ha sido cargado correctamente.";
}else{
echo "Ocurrió algún error al subir el fichero. No pudo guardarse.";
}
?>


