Aqui esta el código:
1. Página con formulario que recibe el archivo: Código PHP:
<?PHP
<center>
<div align="center" id="container">
<h1>Subir una imagen</h1>
<form action="subeimagen.php" method="post" enctype="multipart/form-data" name="form1">
<b>Subir una nueva imágen (max 2 MB): </b><br />
<input name="archivo" type="file" id="archivo" size="40">
<br />
<input name="boton" type="submit" id="boton" style="width:150px; height:35px; font-size:18px" value="^ Subir ^">
</form>
<p><strong style="text-decoration:underline">Instrucciones:</strong><br>
Haz click en <strong>Examinar</strong> y selecciona el achivo a subir. Luego haz click en <strong>Subir</strong>.<br>
No cierres la ventana hasta que termine el proceso de envío.</p>
</div>
</center>
<?PHP
}else{
?>
<center>
<div align="center" id="container">
<h2>Lo sentimos, pero en estos momentos no tenemos habilitada la carga de imagenes</h2>
</div>
</center>
<?PHP
}
?>
</body>
</html>
2. Página que sube la imagen Código PHP:
<html>
<head>
<?PHP
$archivo = $HTTP_POST_FILES['archivo']['name'];
if (is_uploaded_file($HTTP_POST_FILES['archivo']['tmp_name'])) {
if($HTTP_POST_FILES['archivo']['size'] < 524288000) {
copy($HTTP_POST_FILES['archivo']['tmp_name'], $archivo);
$subio = true;
}
if($subio) {
$resultado_f = "<strong>Archivo subido con exito:</strong><br>" . """ . $archivo . """;
$resultado_t = "Archivo subido con exito: " . """ . $archivo . """;
} else {
$resultado_f = "<strong>El archivo no cumple con las reglas establecidas.</strong><br>Solo puedes subir archivos de hasta 500 MB.";
$resultado_t = "Error: El archivo no cumple con las reglas establecidas (max 500 MB)";
}
} else {
$resultado_f = "<strong>Error al subir el Archivo. Inténtalo de nuevo.</strong>";
$resultado_t = "Error: No se pudo guardar el Archivo";
}
echo "<title>Subir Archivos - " . $resultado_t . "</title>";
?>
</head>
<body>
<center>
<div id="container">
<h1>Subir Archivos - Resultados</h1>
<p>
<? echo $resultado_f; ?>
</p>
<a href="index.php">Volver a la galeria</a> - <a href="subir.php">Subir otra imagen</a>
</div>
</center>
</body>
</html>
<? die(); ?>