Buscar este blog

lunes, 14 de octubre de 2013

SUBIR FICHERO CON PHP

ARCHIVO HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<html xmlns="http://www.w3.org/1999/xhtml" lang="es" xml:lang="es">
<link href='http://fonts.googleapis.com/css?family=Boogaloo' rel='stylesheet' type='text/css'>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>PRACTICA SUBIR FICHERO</title>
<link rel="stylesheet" type="text/css" href="PracticaSubirFichero.css" />
</head>
<body>
<form method="post" action="PracticaSubirFicherook.php" enctype="multipart/form-data">
   <input type="file" name="archivo" />
  <input type="submit" value="Subir fichero" />
</form>
 
</body>
</html>
</body>
</html>
______________________________________________________________________
ARCHIVO .PHP

<?php
if (is_uploaded_file($_FILES['archivo']['tmp_name']))
{
   $nombre = $_FILES['archivo']['name'];
   echo "<p>Nombre: <b>". $nombre ."</b></p>";
$origen = $_FILES['archivo']['tmp_name'];
   echo "<p>Origen: <b>". $origen . "</b></p>";
   $destino = realpath("./fichero") . "/" . $_FILES['archivo']['name'];
   echo "<p>Destino: <b>". $destino . "</b></p>";
  move_uploaded_file($origen, $destino);
echo "fichero subido";
}
?>

No hay comentarios:

Publicar un comentario