[eluser]Rubiz'[/eluser]
Well, I tried the upload exemple in the site I'm working now it worked perfect, I though it would be the first time I could use Upload class, but now, I'm using an upload function inside a controller and its returning me the error message "invalid path" ... I just used it as the user guide exemple and it doenst work anymore!!!
What I'm doing wrong????
Code:
if ( $_FILES['img']['name'] != '' )
{
$nomeImg = $this->do_upload( getcwd() . '/upload/', 'img', '118', '123' );
echo $nomeImg;
return;
}
the function
Code:
function do_upload($path, $field_name, $maxWidth = '1280', $maxHeight = '1024')
{
$config['upload_path'] = $path;
$config['allowed_types'] = 'jpg|gif|png|bmp|ppt|pps|pdf';
$config['max_size'] = '10000';
$config['max_width'] = $maxWidth;
$config['max_height'] = $maxHeight;
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload( $field_name ) )
{
$error = array('error' => $this->upload->display_errors());
print_r( $error );
}
else
{
$data = array('upload_data' => $this->upload->data());
return $data['file_name'];
}
}