Ver Mensaje Individual
  #9 (permalink)  
Antiguo 27/01/2009, 16:14
daviteN
 
Fecha de Ingreso: enero-2007
Mensajes: 56
Antigüedad: 18 años
Puntos: 0
Respuesta: Mostrar directorios en menu

Este es mi codigo:
Código PHP:
<?php include("seguridad.php"); ?>
<?php
ini_set
('memory_limit''64M');
  
# DETAILS
  
$UPLOAD_DIR $_POST['directorios'];    # UPLOAD DIRECTORY
  
$max_width  '650';            # WIDTH TO RESIZE IMAGES ABOVE IT
  
$max_height '500';            # HEIGHT TO RESIZE IMAGES ABOVE IT
   
  # DETECT UPLOAD PRESS
  
if(isset($_POST['upload'])){
    
# ADD HERE THE CODE FOR ANY OTHER FIELDS YOU MIGHT HAVE
     
    # GET UPLOADED FILES
    
$photo $HTTP_POST_FILES['photo'];
    foreach(
$photo['name'] as $file_id => $file){
      
# IF FILE IS IMAGE
      
if($file != NULL && (strstr($file'.jpg') || strstr($file'.png') || strstr($file'.gif'))){
        
# REPLACE QUOTES
        
$file str_replace("'""`"$file);
        
$file str_replace('"''`'$file);
        
# COMPOSE URL
        
$url $UPLOAD_DIR.$file;
        
# COPY FILE TO URL
        
if(copy($photo['tmp_name'][$file_id],$url)){
          
# DELETE TMP FILE
          
unlink($photo['tmp_name'][$file_id]);
          
# GET IMAGE DETAILS
          
$data GetImageSize($url);
          
$mime $data['mime'];
          
# IF IMAGE IS BIGGER THEN MAX VALUES
          
if (($data[0] > $max_width) or ($height $max_height)) {
            
# IF WIDTH IS BIGGER
            
if ($data[0] > $max_width) {
              
$width 5000000;
              
$height 5000000;
            }
            
# IF HEIGHT IS BIGGER AFTER WIDTH BASED RESIZE
            
if ($height $max_height) {
              
$height $max_height;
              
$width $data[0]/($data[1]/$height);
            }
            
# CRATE NEW IMAGE
            
$frame ImageCreateTrueColor($width$height);
            
# CRATE FILE IMAGE
            
if ($mime == 'image/gif') {
              
$im ImageCreateFromGIF($url);
            } else if (
$mime == 'image/png') {
              
$im ImageCreateFromPNG($url);
            } else if (
$mime == 'image/jpeg') {
              
$im ImageCreateFromJPEG($url);
            }
            
# RESIZE
            
imagecopyresized ($frame$im0000$width$height$data[0], $data[1]);
            
# WRITE RESIZED IMAGE
            
imagejpeg($frame,$url,80);
            
imagedestroy($frame);
            
imagedestroy($im);
             
            
# ADD HERE THE CODE THAT INSERTS DATA INTO A DATABASE IF YOU WISH
            # FILE NAME VARIABLE IS  $file
          
}
        }
      }
    }
  }
?>
<style type="text/css">
<!--
.Estilo1 {
    font-size: 24px;
    font-weight: bold;
}
-->
</style>

<p align="center" class="Estilo1">Admin Panel AlternativeGC.com.ar </p>
<p><strong>Subir Foto: </strong></p>
<form action='' method='post' enctype='multipart/form-data'>
  <p>PHOTO 1: 
    <input type=file name=photo[]>
    <br>
PHOTO 2: 
<input type=file name=photo[]>
<br>
PHOTO 3: 
<input type=file name=photo[]>
<br>
PHOTO 4: 
<input type=file name=photo[]>
<br>
PHOTO 5: 
<input type=file name=photo[]>
  </p>
  <p>Carpeta : <select name="directorios" id="directorios"> 
<?php 
    
// poner la ruta del directorio, en este caso es el actual 
    
$dir './'
    if (
$fd opendir($dir)) {  
        while ((
$file readdir($fd)) !== false) {  
            
// Si es un directorio y es distinto al actual (.) y al anterior (..) 
            
if (is_dir($dir $file) && $file!="." && $file!="..") { 
                
$opcion '<option value="' $file '">' $file '</option>'
                echo 
$opcion
            } 
         }  
      
closedir($fd);  
    } 
    else { 
        echo 
"<br>No es ruta valida";  
    }  
?> 
</select> 
    <input type="submit" name="upload" value="Upload" />
  </p>
  <p>&nbsp;</p>
  <p>
  
</form>