[eluser]csablotron[/eluser]
hallo all,
as my subject, i have controller:
Code: function input_merchandise(){
$this->load->library(array('upload', 'form_validation'));
if($this->is_logged_in() == TRUE){
$config1 = array(
'upload_path' => $this->images_fotokec_merchandise,
'allowed_types' => 'jpg|jpeg|png',
'max_size' => 1000,
'image_width' => 215,
'image_height' => 130,
);
$config2 = array(
'upload_path' => $this->images_fotobes_merchandise,
'allowed_types' => 'jpg|jpeg|png',
'max_size' => 5000,
'image_width' => 520,
'image_height' => 370,
);
$this->upload->initialize($config1);
$field_fotokec = "fotokec_merchandise";
$this->upload->initialize($config2);
$field_fotobes = "fotobes_merchandise";
if($this->upload->do_upload($field_fotokec) && $this->upload->do_upload($field_fotobes)){
$kecil = $this->upload->initialize($config1);
$data_fotokec = $this->upload->data();
$datafile_fotokec = $data_fotokec['file_name'];
$besar = $this->upload->initialize($config2);
$data_fotobes = $this->upload->data();
$datafile_fotobes = $data_fotobes['file_name'];
$this->MAdminjo->tambahMerchandise($datafile_fotokec, $datafile_fotobes);
$data['main_content'] = 'admins/merchandise/tambah_merchandise';
$this->load->view('admins/template_admin', $data);
}
else{
$data['main_content'] = 'admins/merchandise/tambah_merchandise';
$this->load->view('admins/template_admin', $data);
}
}
else{
$this->load->view('admins/login_form', 'refresh');
}
}
my problem:
when i upload 2 files, why just 1 file name in 2 different field?
example:
field_abc <<< abc.jpg
field_def <<< abc.jpg
Thanks
[eluser]theprodigy[/eluser]
Quote:when i upload 2 files, why just 1 file name in 2 different field?
If you want to change the filename, use the 'file_name' option in the config array:
Code: $config['file_name'] = 'not_abc.jpg';
If you don't set this, then the name of the file will be the same as the name of the file being uploaded.
[eluser]csablotron[/eluser]
hallo theprodigy,
thanks for reply, if i set Code: $config['file_name'] = 'not_abc.jpg';
all of my stored files would be 'not_abc.jpg', right?
i just confused why my stored file name is the same...
thanks
[eluser]theprodigy[/eluser]
Code: $config1 = array(
'upload_path' => $this->images_fotokec_merchandise,
'allowed_types' => 'jpg|jpeg|png',
'max_size' => 1000,
'image_width' => 215,
'image_height' => 130,
'file_name' => 'abc.jpg'
);
$config2 = array(
'upload_path' => $this->images_fotobes_merchandise,
'allowed_types' => 'jpg|jpeg|png',
'max_size' => 5000,
'image_width' => 520,
'image_height' => 370,
'file_name' => 'not_abc.jpg'
);
Something like this. You may not want to hard code the file names in. You may want to use a variable like you did for upload_path, or find some other way to make it dynamic, but you get the idea.
[eluser]csablotron[/eluser]
thanks theprodigy,
i've solve the problem... this ini my code:
Code: function input_merchandise(){
$this->load->library(array('upload', 'form_validation'));
if($this->is_logged_in() == TRUE){
$config1 = array(
'upload_path' => $this->images_fotokec_merchandise,
'allowed_types' => 'jpg|jpeg|png',
'max_size' => 1000,
'image_width' => 215,
'image_height' => 130,
);
$config2 = array(
'upload_path' => $this->images_fotobes_merchandise,
'allowed_types' => 'jpg|jpeg|png',
'max_size' => 5000,
'image_width' => 520,
'image_height' => 370,
);
$this->upload->initialize($config1);
$field_fotokec = "fotokec_merchandise";
$this->upload->do_upload($field_fotokec);
$data_fotokec = $this->upload->data();
$datafile_fotokec = $data_fotokec['file_name'];
$this->upload->initialize($config2);
$field_fotobes = "fotobes_merchandise";
$this->upload->do_upload($field_fotobes);
$data_fotobes = $this->upload->data();
$datafile_fotobes = $data_fotobes['file_name'];
$this->MAdminjo->tambahMerchandise($datafile_fotokec, $datafile_fotobes);
$data['main_content'] = 'admins/merchandise/tambah_merchandise';
$this->load->view('admins/template_admin', $data);
}
else{
$this->load->view('admins/login_form', 'refresh');
}
}
thanks for your attention
|