Saturday, 14 September 2013

Use do_upload twice

Use do_upload twice

i would like to upload 2 files to different path but at the first path
it's work properly but when it use next path its error with "The filetype
you are attempting to upload is not allowed."
Model
$this->load->model('blogmaintain_helper');
$data['cover_path'] = $this->blogmaintain_helper->upload_cover();
$data['file_path'] = $this->blogmaintain_helper->upload_file();
Controller
function upload_cover(){
$config_cover['upload_path'] =
'ftp://[server_path]/public_html/img/blog/';
$config_cover['allowed_types'] = 'gif|jpg|png|tif';
get_instance()->load->library('upload', $config_cover);
if($this->upload->do_upload('myFile'))
{
echo "Cover upload success";
return true;
}
else
{
echo $this->upload->display_errors();
}
}
function upload_file(){
$config_file['upload_path'] =
'ftp://[server_path]/public_html/document/blog/';
//$config['upload_path'] = 'document/blog/';
$config_file['allowed_types'] = 'doc|docx|pdf|txt|xls|xlsx|ppt|pptx';
get_instance()->load->library('upload', $config_file);
if($this->upload->do_upload('myDoc'))
{
echo "File upload success";
}
else
{
echo $this->upload->display_errors();
}
}
i can upload myFile to img/blog but when it perform 'upload_file' it's
error with "The filetype you are attempting to upload is not allowed."
PS* myDoc is "test.txt" and myFile is "pic.jpg"

No comments:

Post a Comment