Ver Mensaje Individual
  #2 (permalink)  
Antiguo 28/08/2008, 09:55
Avatar de masterojitos
masterojitos
 
Fecha de Ingreso: julio-2008
Ubicación: Lima Callao Chucuito
Mensajes: 1.931
Antigüedad: 15 años, 9 meses
Puntos: 105
Respuesta: Cargar Archivos con PHP

Varon aqui te paso un codigo resencillo, y se que te va servir:

Archivo: upload.php
Código PHP:
<?php 
$status 
"";
if (
$_POST["action"] == "upload") {
    
// obtenemos los datos del archivo 
    
$tamano $_FILES["archivo"]['size'];
    
$tipo $_FILES["archivo"]['type'];
    
$archivo $_FILES["archivo"]['name'];
    
$prefijo substr(md5(uniqid(rand())),0,6);
    
    if (
$archivo != "") {
        
// guardamos el archivo a la carpeta files
        
$destino =  "files/".$prefijo."_".$archivo;
        if (
copy($_FILES['archivo']['tmp_name'],$destino)) {
            
$status "Archivo subido: <b>".$archivo."</b>";
        } else {
            
$status "Error al subir el archivo";
        }
    } else {
        
$status "Error al subir archivo";
    }
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>PHP upload - MasterOjitos</title>
<link href="estilo.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="413" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="413" height="40" class="titulo">PHP upload - MasterOjitos</td>
  </tr>
  <tr>
    <td class="text">Por favor seleccione el archivo a subir:</td>
  </tr>
  <tr>
  <form action="upload.php" method="post" enctype="multipart/form-data">
    <td class="text">
      <input name="archivo" type="file" class="casilla" id="archivo" size="35" />
      <input name="enviar" type="submit" class="boton" id="enviar" value="Upload File" />
      <input name="action" type="hidden" value="upload" />      </td>
    </form>
  </tr>
  <tr>
    <td class="text" style="color:#990000"><?php echo $status?></td>
  </tr>
  <tr>
    <td height="30" class="subtitulo">Listado de Archivos Subidos </td>
  </tr>
  <tr>
    <td class="infsub">
    <?php 
    
if ($gestor opendir('files')) {
        echo 
"<ul>";
        while (
false !== ($arch readdir($gestor))) {
           if (
$arch != "." && $arch != "..") {
               echo 
"<li><a href=\"files/".$arch."\" class=\"linkli\">".$arch."</a></li>\n";
           }
        }
        
closedir($gestor);
        echo 
"</ul>";
    }
    
?>    </td>
  </tr>
</table>
</body>
</html>
archivo estilo.css
Código HTML:
.titulo {
	font-family: "Trebuchet MS", Verdana;
	font-size: 18px;
	font-weight: bolder;
	color: #990000;
	text-decoration: none;
	border-top-width: 1px;
	border-bottom-width: 2px;
	border-top-style: solid;
	border-bottom-style: solid;
	border-top-color: #D4D0C8;
	border-bottom-color: #D4D0C8;
	text-align: left;
	padding-left: 30px;
}
.casilla {
	font-family: "Trebuchet MS", Verdana;
	font-size: 11px;
	font-weight: normal;
	color: #999999;
	text-decoration: none;
	border: 1px solid #D4D0C8;
}
.boton {
	border: 1px solid #D4D0C8;
	font-family: "Trebuchet MS", Verdana;
	font-size: 10px;
	font-weight: bold;
	color: #990000;
	text-decoration: none;
	background-color: #D4D0C8;
	vertical-align: middle;
}
.subtitulo {
	font-family: "Trebuchet MS", Verdana;
	font-size: 16px;
	font-weight: bolder;
	color: #999999;
	text-decoration: none;
	text-align: left;
	padding-left: 30px;
}
.subtitulo:hover {
	font-family: "Trebuchet MS", Verdana;
	font-size: 16px;
	font-weight: bolder;
	color: #999999;
	text-decoration: underline;
	text-align: center;
}
.subtext {
	font-family: "Trebuchet MS", Verdana;
	font-size: 12px;
	font-weight: normal;
	color: #999999;
	text-decoration: none;
	text-align: left;
	padding-left: 30px;
	background-color: #EFEFEF;
}
.infsub {

	font-family: "Trebuchet MS", Verdana;
	text-decoration: none;
	border-top-width: 1px;
	border-top-style: solid;
	border-top-color: #D4D0C8;
}
.text {
	font-family: "Trebuchet MS", Verdana;
	font-size: 12px;
	font-weight: normal;
	color: #999999;
	text-decoration: none;
	text-align: left;
	padding-left: 30px;
	padding-top: 10px;
}
.link {

	font-family: "Trebuchet MS", Verdana;
	font-size: 12px;
	font-weight: bolder;
	color: #990000;
	text-decoration: none;
	text-align: center;
}
a.link:hover {


	font-family: "Trebuchet MS", Verdana;
	font-size: 12px;
	font-weight: bolder;
	color: #990000;
	text-decoration: underline;
	text-align: center;
}
li {
	list-style-type: circle;
	font-size: 16px;
	text-decoration: none;
}
.linkli {


	font-family: "Trebuchet MS", Verdana;
	font-size: 12px;
	font-weight: normal;
	color: #0000C0;
	text-decoration: none;
}
a.linkli:hover {



	font-family: "Trebuchet MS", Verdana;
	font-size: 12px;
	font-weight: normal;
	color: #0000C0;
	text-decoration: underline;
}
y por ultimo te creas una carpeta files.... donde se almacenaran los correos.....

espero te sirva.

Atte.

MasteerOjitos