Ver Mensaje Individual
  #1 (permalink)  
Antiguo 05/07/2012, 12:33
likuid1444
 
Fecha de Ingreso: julio-2012
Mensajes: 2
Antigüedad: 11 años, 10 meses
Puntos: 0
subida multiple de archivos php

hola,

tengo unos problemillas en php haber si me podeis guiar un poquito por el camino,
estoy intentando subir multiples archivos en php, y tan solo me consigue subir uno.

os pongo el codigo utilizado.
formulario:
Código PHP:
function get_string(){
        if( 
strlen($this->onblur) ) $javascript "onblur=\"{$this->onblur}\"";
        else 
$javascript="";
        
/*if( !empty($this->title) ) $ret = $this->title."";
         else $ret = "";*/ 
$ret="";
        return 
$ret."<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"{$this->maxsize}\"/><input type=\"file\" multiple class=\"{$this->cssclass}\" name=\"{$this->key}[]\" size=\"{$this->size}\" $javascript {$this->tag_extra}/>\n";
    } 
subida:
Código PHP:
function process(){

        if (isset(
$_FILES["$this->key"]['tmp_name']) && $_FILES["$this->key"]['tmp_name']!="" /*&& is_uploaded_file($_FILES["$this->key"]['tmp_name'])*/ ){

            
$tot count($_FILES["$this->key"]['name']);
            
            
//$tot = $_POST[$_FILES["$this->key"];
            
$nombreCampo "$this->key";
            for(
$i 0$i $tot$i++){
                
// Making file name writable
                
$accents '/&([A-Za-z]{1,2})(grave|acute|circ|cedil|uml|lig);/';
                
$string preg_replace($accents,'$1',$_FILES[$nombreCampo]['name'][$i]);
                
// clean out the rest
                
$replace = array('([\40])','(\'|,|%)','([^a-zA-Z0-9.])','(-{2,})');
                
$with = array('_','_','','_');
                
$string strtolower(preg_replace($replace,$with,$string));            
                
/*$image=substr(md5(uniqid("")), 0, 4 + $i).$i.$string;*/
                
$image=substr(md5(uniqid("")), 04).$string;
                
// End Filename Writable
                
                
if (file_exists($this->uploadfolder.$image)) unlink($this->uploadfolder.$image);
                
$this->image_uploaded=$image;
                if (!
move_uploaded_file($_FILES[$nombreCampo]['tmp_name'][$i], $this->uploadfolder.$image)){
                    
$this->image_uploaded=false;
                } else
                    
$this->value=$image;
            }
        }
        else 
$this->image_uploaded=false;
    
    }