Ver Mensaje Individual
  #7 (permalink)  
Antiguo 09/08/2009, 13:00
Avatar de kuriel
kuriel
 
Fecha de Ingreso: febrero-2009
Mensajes: 240
Antigüedad: 17 años, 7 meses
Puntos: 4
Pregunta Respuesta: Alguien que sepa: Upload + Secuencia númerica, ej: 1, 2, 3, 4, n...

A ver, tengo el siguiente upload, "He tratado de incluir el codigo que me haz dado":

Código PHP:
<body>
<form action="upload.php" method="post" ENCTYPE="multipart/form-data">
<input type="file" name="file" size="30"> <input id="botoninput" type="submit"
value="Subir!">
</form>

 <?php 
    
if ($gestor = opendir('mp3')) {
    
        while (
false !== ($arch = readdir($gestor))) {
           if (
$arch != "." && $arch != "..") {
               echo 
"<ul>";
               echo 
"<li><img src=mp3.jpg width=16 height=16></img><a href=\"mp3/".$arch."\" target=_blank>$arch - xxx.sub.es</a></li>\n";
               echo 
"</ul>";
           }
        }
        
closedir($gestor);
    
    }



?>

<style type="text/css">
td {display:none;}
a {text-decoration:none; color:green; font:15px bold Tahoma, Geneva, sans-serif; margin-top:-4px;}
body {background:url();}
#botoninput {width:70px; height:25px; background:#CCC; border:2px solid #333; text-align:center;}
li {list-style:none; margin-left:-30px;}
</style>

<?php
// ==============
// Configuration
// ==============
$uploaddir = "mp3"; // Carpeta donde se subiran los archivos
$allowed_ext = "mp3, mid"; // Extenciones permitidas
$max_size = "9000000000"; // Tamaño en Kb
$max_height = ""; // Pixeles si deseo subir imagenes
$max_width = ""; // Pixeles de ancho si quiero subir imagenes

// Vemos la extencion
$extension = pathinfo($_FILES['file']['name']);
$extension = $extension[extension];
$allowed_paths = explode(", ", $allowed_ext);
for(
$i = 0; $i < count($allowed_paths); $i++) {
if (
$allowed_paths[$i] == "$extension") {
$ok = "1";
}
}

// Checamos el tamaño del archivo
if ($ok == "1") {
if(
$_FILES['file']['size'] > $max_size)
{
print 
"Archivo demaciado grande!";
exit;
}

// Si es imagen, checamos el alto y ancho en pixeles
if ($max_width && $max_height) {
list(
$width, $height, $type, $w) =
getimagesize($_FILES['file']['tmp_name']);
if(
$width > $max_width || $height > $max_height)
{
print 
"Alto o Ancho exeden lo permitido!";
exit;
}
}
//Checar si el nombre no es el mismo

$c = 1;
$ok = false;

while (
$ok == "false") {


if(
file_exists($uploaddir/".$c.".ext)) {
$c++;
else {
$ok = true;

move_uploaded_file($_FILES['file']['tmp_name'],$uploaddir.'/'.$_FILES['file']['name']);
 
// Engrane del upload
if(is_uploaded_file($_FILES['file']['tmp_name']))
{
move_uploaded_file($_FILES['file']['tmp_name'],$uploaddir.'/'.$_FILES['file']['name']);
}

            
echo 
"Archivo subido con exito! <a href=upload.php>Actualizar pagina</a>";
} else {
print 
"Archivos permitidos: mp3";
}

?>


</body>
<Y me indica error en la linea 88>