views:

34

answers:

2

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?

A: 

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);
        }
 }
stormdrain
I tried changing it up a bit. I moved the functionality into the controller. Here's what my controller looks like now. I'm getting the same result though. the page comes back and no images have been uploaded. http://pastebin.com/anFP67rf
Jason Shultz
Stormdrain, that's not true. Models are ment for any form of data interaction whether it's via a database or a file (or anything else). Putting uploading related code in a model is perfectly fine.
Yorick Peterse
@Yorick Peterse: From the CI userguide:"Models are PHP classes that are designed to work with information in your database."http://codeigniter.com/user_guide/general/models.html
stormdrain
@Jason Shultz:put your upload inside your `if` statement as shown above. By trying to create another function inside the controller `$this->do_upload()`, you're not actually passing the data to CI's `do_upload()` so nothing is getting uploaded. http://pastebin.com/AhDmTb2Y
stormdrain
@stormdrain That's how the CI user guide describes it, the MVC pattern describes it as a general business layer meaning it can be used for much more than database access. It's a common mistake people make.
Yorick Peterse
A: 

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);
DRL
Here's the messages I'm getting:The upload path does not appear to be valid.You did not select a file to upload.array(13) { ["file_name"]=> string(0) "" ["file_type"]=> string(0) "" ["file_path"]=> string(0) "" ["full_path"]=> string(0) "" ["raw_name"]=> string(0) "" ["orig_name"]=> string(0) "" ["file_ext"]=> string(0) "" ["file_size"]=> string(0) "" ["is_image"]=> bool(false) ["image_width"]=> string(0) "" ["image_height"]=> string(0) "" ["image_type"]=> string(0) "" ["image_size_str"]=> string(0) "" } string(48) "/home/verdebus/public_html/assets/images/gallery"
Jason Shultz
I checked the file extensions and they're correct. i've tried hardcoding the upload path, removing /home/verdebus from it and just using /public/html/assets/images/gallery and that didn't work. and i've tried it with and without a trailing slash. still no go.
Jason Shultz