I am using Codeigniter and I am trying to upload multiple files into a database. The files are seperate fields not multiple files for one field.
Post-http :/ / codeigniter.com/forums/viewthread/110130/P0 / izledi
Neredeyse çalışma var ama benim db içine yüklenen veri ekleme ile bazı sorun yaşıyorum.
İşte benim denetleyicisi işlevi ...
function addStation(){
// set common properties
$data['title'] = 'Add new station';
$data['action'] = site_url('admin/station/addStation');
$data['link_back'] = anchor('admin/station/index/','Back to list of stations',array('class'=>'back'));
// set validation properties
$this->_set_fields();
$this->_set_rules();
$config['allowed_types'] = 'pdf|xls|doc|docx';
$config['max_size'] = '1000';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$path_to_uploads='./uploads/files/stations';
$config['upload_path'] = $path_to_uploads;
// File specific (overrule global and optional)
$config['logo_file']['upload_path'] = './uploads/images/stations';
$config['logo_file']['allowed_types'] = 'gif|jpg|png';
$this->load->library('upload', $config);
//add this
$this->upload->initialize($config);
if (!$this->upload->do_upload(array('rajar_file','playlist_file','map_file', 'logo_file'))){
$error = $this->upload->display_errors();
echo "<script>alert($error);</script>";
}else{
$data = array('upload_data' => $this->upload->data(array('rajar_file','playlist_file','map_file', 'logo_file')));
$rajar_file_name = $upload_data['rajar_file']['file_name'];
$rajar_full_file_path = $path_to_uploads.'/'.$rajar_file_name;
$playlist_file_name = $upload_data['playlist_file']['file_name'];
$playlist_full_file_path = $path_to_uploads.'/'.$playlist_file_name;
$map_file_name = $upload_data['map_file']['file_name'];
$map_full_file_path = $path_to_uploads.'/'.$map_file_name;
$logo_file_name = $upload_data['logo_file']['file_name'];
$logo_full_file_path = $path_to_uploads.'/'.$logo_file_name;
}
// run validation
if ($this->validation->run() == FALSE){
$data['message'] = '';
}else{
// save data
$station = array('name' => $this->input->post('name'),
'rajar' => $rajar_full_file_path,
'playlist' => $playlist_full_file_path,
'map' => $map_full_file_path,
'logo' => $logo_full_file_path );
$id = $this->stationModel->save($station);
// set form input name="id"
$this->validation->id = $id;
// set user message
$data['message'] = '<div class="success">add new station success</div>';
}
$this->template->set('title', 'Admin - Add New Station!');
$this->template->load('admin/template', 'admin/stationEdit', $data);
}
Form gönderildikten sonra aşağıdaki hataları olsun ...
Mesaj: Undefined variable: rajar_full_file_path
Mesaj: Undefined variable: playlist_full_file_path
Mesaj: Undefined variable: map_full_file_path
Mesaj: Undefined variable: logo_full_file_path
Ben aptal oluyorum, ben bunu çözemiyorum?
Thanks Dan