1
我試圖使用codeigniter文件上傳庫上傳多個圖像,但它只上傳一個文件,即使選擇了多個文件。請協助Codeigniter只上傳一個圖像而不是多個
//uploading images
public function upload_image() {
$this->load->helper('form');
$config = array(
'upload_path' => "./image_uploads/",
'allowed_types' => "jpg|png|jpeg",
'overwrite' => TRUE,
'max_size' => "2048000", // Can be set to particular file size , here it is 2 MB(2048 Kb)
'max_height' => "768",
'max_width' => "1024"
);
$this->load->library('upload', $config);
var_dump($_FILES); die();
foreach ($_FILES as $key => $userfileObject) {
if (!empty($userfileObject['name'])) {
$this->upload->initialize($config);
var_dump($_FILES['userfile']);
if (!$this->upload->do_upload($_FILES[$key])) {
$errors = $this->upload->display_errors();
flashMsg($errors);
} else {
// Code After Files Upload Success GOES HERE
$data['content'] = 'success';
$this->load->view('templates/template', $data);
}`enter code here`
}
}
}
是「菊花」 – Kabs
我上傳不同的文件名如文件。 '沙漠'和'菊花',它選擇了最後一個......我怎麼去解決它...? – Kabs