Ver Mensaje Individual
  #6 (permalink)  
Antiguo 06/06/2013, 10:37
Avatar de enlinea777
enlinea777
 
Fecha de Ingreso: mayo-2008
Ubicación: frente al pc
Mensajes: 1.830
Antigüedad: 15 años, 11 meses
Puntos: 127
Respuesta: Ordenar Archivos Subidos Por Upload

Cita:
Iniciado por eprado Ver Mensaje
Segun me codigo me podrias indicar como leer la fecha ya que estan guardados en un directorio de la PC
ok aqui el codigo:

con un pequeño plus:

Código PHP:
<?php 
$status 
"";

$action = isset($_POST['action']) ? $_POST['action'] : 'archivo'
  if (
$action == "upload" ){
    
// obtenemos los datos del archivo 
    
    
$tamano $_FILES["archivo"]['size'];
    
$tipo $_FILES["archivo"]['type'];
    
$archivo $_FILES["archivo"]['name'];
    
$prefijo $_POST["dato"];
    
    if (
$archivo != "") {
        
// guardamos el archivo a la carpeta files
        
$destino =  "files/".$prefijo."---".$archivo;
        
        
        if (
file_exists("files/" $_FILES['archivo']['tmp_name'])) {
          
$destino=  $_FILES['archivo']['tmp_name'] . " ya existe. ";
        }
        else{
        if (
copy($_FILES['archivo']['tmp_name'],$destino)) {
            
$status "Archivo subido: <b>".$archivo."</b>";
            
        
        } else {
            
$status "Error al subir el archivo";
        }
    
    }
    }

    
 

}

?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Subir Guiones</title>
<link href="estilo.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="413" border="0" cellspacing="0" cellpadding="0" align="center" >
  <tr>
    
   
    <td width="413" height="40" align="center"><a href="index.php?menu=Principal"><img src="images/tv_ead.jpg" width="225" height="100" align="absbottom" border="0"> </td>
  
 
  </tr>
  
  
  <table border="0" align="center">
  <tr>
    <td class="text">Por favor seleccione el archivo a subir: <a href="MODELO GUIÓN AUDIOS.docx">Modelo de Guion</a></td>
  </tr>
  <tr>
  
  <form action="upload.php" method="post" enctype="multipart/form-data">
    <td class="text">
      Nro Solicitud
      <input name="dato" type="text" class="casilla" id="dato" size="20"  />
      <input name="archivo" type="file" class="casilla" id="archivo" size="35" />
      <input name="enviar" type="submit" class="boton" id="enviar" value="Subir Guion" />
      <input name="action" type="hidden" value="upload" />      
       
      
      </td>
      
    </form>
  </tr>

  <tr>
    <td class="text" style="color:#990000"><?php echo $status?></td>
  </tr>
 
  <tr>
   
  </tr>
  <tr>
     </table>
    
    <table border="0" align="left">
    <tr>
    <td height="30" class="subtitulo">Listado de Archivos Subidos <img src="images/modif.png" width="50" height="50" align="absbottom" border="0"> </td>
  </tr>
    <td class="infsub">
      
    <?php 
function bytestostring($size$precision 0) {
    
$sizes = array('YB''ZB''EB''PB''TB''GB''MB''kB''B');
    
$total count($sizes);

    while(
$total-- && $size 1024$size /= 1024;
    return 
round($size$precision).$sizes[$total];
}
function 
ver_extencion($dato){
$tipo=substr($dato,strrpos($dato,".")+1);
return 
$tipo;
}
function 
leer_dir(){ //Funcion que hace la MAGIA
    
if ($gestor opendir('files')) {
        while (
false !== ($archivo readdir($gestor))) {
            
$ARCH=ver_extencion($archivo);// reviso la extencion por logeneral no se usa
          
if ($arch != "." && $arch != "..") {
            
$Tam=bytestostring(filesize("files/".$archivo));
            
$todo[filemtime("files/".$archivo)]=array($archivo,$Tam);// agrego un array con la fecha del archivo
            
}
        }
    }
        
closedir($gestor);
        
krsort($todo);// reordena los resultados por fecha
    
return $todo;    
}
    
    
$archivos=leer_dir();//REALIZA un arreglo o array
    
?><ul><?
for($i=0$i<count($archivos); $i++){
    
$dato=current($archivos);
    
$arc=$dato[0];
    
$tam=$dato[1];
    
?>
<li><a href="files/<?=$arc?>" class="linkli"><?=$arc?></a> ----  <?=$tam?></li>
    <?
    next
($archivos);
    }
    
?></ul>
</td>
  </tr>
<tr>
</table>
</body>
</html>

dime si funciona.