Attila Naghi
Attila Naghi

Reputation: 2686

Codeigniter Upload File Issue

Hi this is my code:

$config['upload_path'] = $_SERVER['DOCUMENT_ROOT'].'/licenta/application/images/products';
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size'] = '2048';
        $x = $this->load->library('upload', $config);
        if (!$this->upload->do_upload()){
             //failed
        }else{
             //success
        }

This is: $this->upload->do_upload() always false. My form is correct I get the right data if I use var_dump($_FILES);. The path is:

C:/xampp/htdocs/licenta/application/images/products

I tried also this version /images/products/ or ./images/products/ or ../images/product/. None of them are working. I am using XAMPP. What else should be the problem? I check the others post and the documentation and for them are working, for me is not. Can someone help me? I am stuck :(

Upvotes: 0

Views: 40

Answers (1)

Raghbendra Nayak
Raghbendra Nayak

Reputation: 1646

Just pass the HTML field name attribute in do_upload() function: See below code:

$this->upload->do_upload('userfile');

I hope it will work.

Upvotes: 1

Related Questions