我有一個文件上傳器。我通過數據進行覆蓋。這讓我將這些數據上傳: - Pict1.jpg - Pict12.jpg - Pict13.jpgCodeigniter - PHP數組返回單個數據
但是,當我試圖返回它,它只是顯示pict1.jpg。下面的代碼
控制器:
function send(){
$mariupload = $this->upload_gambar($_FILES['gambar']);
if ($mariupload === FALSE) {
$upload = false;
}
if($upload = false){
$error = array('error' => $this->upload->display_errors());
$this->load->view('upload_form', $error);
} else {
$dataupload = $mariupload;
echo $dataupload;
}
private function upload_gambar($files){
//config buat upload gambar
$config['upload_path'] = 'path to upload';
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$config['max_size'] = '1024';
$config['overwrite'] = '0';
$this->load->library('upload', $config);
$gambar = array();
if (is_array($files['name']) || is_object($files['name'])){
foreach ($files['name'] as $key => $gambar) {
$_FILES['gambar[]']['name']= $files['name'][$key];
$_FILES['gambar[]']['type']= $files['type'][$key];
$_FILES['gambar[]']['tmp_name']= $files['tmp_name'][$key];
$_FILES['gambar[]']['error']= $files['error'][$key];
$_FILES['gambar[]']['size']= $files['size'][$key];
$fileName = $gambar;
$images[] = $fileName;
$config['file_name'] = $fileName;
$this->upload->initialize($config);
if ($this->upload->do_upload('gambar[]')) {
$dataupload = $this->upload->data('file_name');
return $dataupload.'<br>';
} else {
$mariupload = false;
}
}
}
}
當我嘗試回聲$ dataupload在upload_gambar功能,它可以作爲一個數組。但它作爲單個數據返回發送()函數。任何想法?
編輯了$ mariupload。但是當我將gambar []變成gambar時,它變成了NULL。我有一個5個單獨的上傳器,將在1次提交中合併爲1個數組 –