Yup. The title says it all. I have two file upload functions in a view and they need two different configs to upload files.
echo form_label('Product Image') . form_upload('prod_image','');
echo form_label('Product Manual') . form_upload('prod_manual','');
As the names imply, the first upload form should contain only an image file and upload it to an image folder. The other should contain only a doc/pdf file and upload it to a manual folder.
In a controller, how can I give them two different configs? I can't find any info regarding it
Thank you in advance!
//open single form is enough and target to this method update the form field name appropriate to the document and image
//controlleer method
function do_upload()
{
//upload image
if($this->upload_image('field_name'))
{
//upload dsuccess
}else{
//error
}
//upload image
if($this->upload_document('field_name'))
{
//upload dsuccess
}else{
//error
}
}
//controlleer method
function upload_image($form_field_name)
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload($form_field_name))
{
return false;
}
else
{
return true;
}
}
//controlleer method
function upload_document($form_field_name)
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'doc|pdf';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload($form_field_name))
{
return false;
}
else
{
return true;
}
}