2012-03-25 8 views
0

Also lade ich jede Bilddatei über mein tolles Upload-Formular hoch und lädt es zweimal hoch (zB name, name1). Code in der Modellfunktion verantwortlich für den Upload unter:Codeigner lädt dieselbe Datei zweimal hoch

function do_upload() { 
    if(isset($_POST['media'])) { 
     $config = array( 
      'allowed_types' => 'jpg|jpeg|gif|png|pdf', 
      'upload_path' => $this->path; 
     ); 
     $this->load->library('upload', $config); 
     $i = 1; 
      while($i < ($this->input->post('value')+1)) { 
       $this->upload->do_upload('attachment'.$i); 
       if(!$this->upload->do_upload('attachment'.$i)) echo $this->upload->display_errors(); 
       echo "added attachment".$i."<br/>"; 
       $i = ++$i; 
     } 
    } else { echo "nothing passed"; } 
} 

in Chrom-Entwickler-Tool i sehe normale Post-Anforderung mit Dateien sendet i laden, aber es erstellt im Ordner verdoppelt. irgendwelche Ideen?

Prost!

Antwort

1

Sie rufen die Methode $ this-> upload-> do_upload zweimal in Ihrer while-Schleife auf. Entfernen Sie die erste Zeile vor der if-Anweisung.

+0

danke! mein Fehler :) habe nicht gedacht, dass es tatsächlich in der if-Anweisung ausgeführt wird! – mjanisz1

Verwandte Themen