Ver Mensaje Individual
  #3 (permalink)  
Antiguo 26/09/2007, 22:02
lana27
 
Fecha de Ingreso: septiembre-2007
Mensajes: 73
Antigüedad: 16 años, 7 meses
Puntos: 0
Re: Eliminar una imagen sin tener base de datos

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&aacute;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</strongy selecciona el achivo a subirLuego haz click en <strong>Subir</strong>.<br>
    
No cierres la ventana hasta que termine el proceso de env&iacute;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>" "&quot;" $archivo "&quot;";
        
$resultado_t "Archivo subido con exito: " "&quot;" $archivo "&quot;";
    } 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&eacute;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(); ?>