Jason Shultz
Jason Shultz

Reputation: 970

Problem with Gallery Uploading

I've got an image uploader that doesn't upload images. I'm not receiving any errors and i've checked the folder permissions and even on 777 no images are getting uploaded.

You can see the code here: http://pastebin.com/gvH1dKh9

The value for gallery_path is /home/domain/public_html/assets/images/gallery

The value for gallery_path_url is http://domain.com/assets/images/gallery/

I have used this same code on another site with zero problems. I'm not sure what the problem is with this site?

Upvotes: 0

Views: 176

Answers (3)

Bender
Bender

Reputation: 11

Use

$this->load->library('upload', $config); 

instead of

$this->upload->initialize($config);

In my case it was helpful

Upvotes: 1

Bella
Bella

Reputation: 3217

Try doing some error checking on your upload:

if(! $this->upload->do_upload('Filedata')){
     echo $this->upload->display_errors();
}
$upload_info = $this->upload->data();

echo var_dump($upload_info);

Upvotes: 0

stormdrain
stormdrain

Reputation: 7895

Models are intended for interaction with databases. Try moving your upload code into the controller, then if needed take the returned data ($this->upload->data();) and pass that to a model for insertion to a database.

function index() {
        $this->load->model('Gallery_model');
        if ($this->input->post('upload')) {
                $config = array(
                        'allowed_types' => 'jpg|jpeg|gif|png',
                        'upload_path' => '/uploads',
                        'max_size' => 2000
                );

                $this->load->library('upload', $config);
                $this->upload->do_upload();
                $image_data = $this->upload->data();
                $this->Gallery_model->insertImageData($image_data);
        }
 }

Upvotes: 0

Related Questions