Welcome Guest, Not a member yet? Register   Sign In
What I am doing wrong?
#1

[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'];
        }
    }
#2

[eluser]rsmithinfo[/eluser]
When you say it doesn't work what do you mean? Does it report any error messages? Anything in the log? Does your print_r return anything?
#3

[eluser]tonanbarbarian[/eluser]
does the upload folder exist
in particular check that
Code:
getcwd() . '/upload/'
folder exists
i would echo that value out to be sure
you mahe find the getcwd is returning a different value than u expected
#4

[eluser]Rubiz'[/eluser]
rsmithinfo & tonanbarbarian, thanx for answering!!

Its very very weird cause I got echo from path, it's right, and the class always returns invalid path...
First time I tried the user guide example as it is the same path simply worked.

I really dont know what it could be...




Theme © iAndrew 2016 - Forum software by © MyBB