Mit meinem Code unter es kann nur die einzelne Datei hochgeladen werden, aber kann nicht mehrere Dateien hochladen bitte beraten Sie mich, was ich falsch mache.Kann nicht mehrere Dateien mit CodeIgniter 3 hochladen
Hier ist die Fehlermeldung.
Array ([Fehler] => Sie nicht ausgewählt haben, eine Datei hochzuladen.
)
UPDATE meine Frage wenn ich
echo $i.":".$_FILES['file_upload']['name'][$i].'<br/>';
Hier ist das Ergebnis
0: Heading-Titel-bg.jpg 1: varun.jpg
Aber nachdem ich den Code
geändert$_FILES['file_upload']['name'] = $_FILES['file_upload']['name'][$i];
echo $i.":".$_FILES['file_upload']['name'].'<br/>';
Hier ist das Ergebnis:
0 : heading-title-bg.jpg 1: e
// CONTROLLER
public function addPhoto(){
if (!empty($_FILES)):
$count = count($_FILES['file_upload']['name']);
for($i =0; $i<$count;$i++):
$_FILES['file_upload']['name'] = $_FILES['file_upload']['name'][$i];
$_FILES['file_upload']['type'] = $_FILES['file_upload']['type'][$i];
$_FILES['file_upload']['tmp_name'] = $_FILES['file_upload']['tmp_name'][$i];
$_FILES['file_upload']['error'] = $_FILES['file_upload']['error'][$i];
$_FILES['file_upload']['size'] = $_FILES['file_upload']['size'][$i];
$config['upload_path'] = './uploads/employee/';
$config['allowed_types'] = 'jpg|png';
$config['max_size'] = 5000;
$config['max_width'] = 0;
$config['max_height'] = 0;
$config['overwrite'] = FALSE;
$config['remove_spaces'] = TRUE;
$this->load->library('upload', $config);
$this->upload->initialize($config);
if($this->upload->do_upload('file_upload')){
$data = $this->upload->data();
echo "<pre>";
print_r($data);
echo "</pre>";
}else{
$error = array('error' => $this->upload->display_errors());
print_r($error);
}
endfor;
endif; //$_FILE
}
VIEW
<input type="file" name="file_upload[]" class="form-control-file" id="fileUpload" multiple>
Warum zählen Sie auch die '[ 'name']' Feld –
was bekommen u, wenn Sie tun: 'var_dump ($ _ FILES [ 'file_upload']); die();' Recht vor, die Spitze der Funktion? – Sletheren
array (5) { [ "name"] => array (2) { [0] => string (38) "Screen Shot 2560.08.28 bei 13.40.35.png" [1] => string (38) "Screen Shot 2560-08-28 um 19.47.01.PNG“ } [ "type"] => array (2) { [0] => string (9) "image/PNG" [1] => string (9) "image/PNG" } [ "tmp_name"] => array (2) { [0] => string (14) "/ tmp/phpJnbSu4" [1] => string (14) "/ tmp/phpUMFg8l" } [ "error"] => array (2) { [0] => int (0) [1] => int (0) } [ "size"] => 0.123.array (2) { [0] => int (110.397) [1] => int (83195) } } – xDevelopers