Welcome Guest, Not a member yet? Register   Sign In
Image Manipulation Trouble
#1

[eluser]Antonius Willson[/eluser]
Someone can help me.
I can't display thumbs image ...
This is the model code :

Code:
<?php
class Gallery_model extends CI_Model {
    
    var $gallery_path;
    var $gallery_path_url;
    
    function __construct() {
        parent::__construct();
        
        $this->gallery_path = (APPPATH . '../images');
        $this->gallery_path_url = '/images/';
    }
    
    function do_upload() {
        
        $config = array(
            'allowed_types' => 'jpg|jpeg|gif|png',
            'upload_path' => $this->gallery_path,
            'max_size' => 2000
        );
        
        $this->load->library('upload', $config);
        $this->upload->do_upload();
        $image_data = $this->upload->data();
        
        $config = array(
            'source_image' => $image_data['full_path'],
            'new_image' => $this->gallery_path . '/thumbs',
            'maintain_ration' => true,
            'width' => 150,
            'height' => 100
        );
        
        $this->load->library('image_lib', $config);
        $this->image_lib->resize();
        
    }
    
    function get_images() {
        
        $files = scandir($this->gallery_path);
        $files = array_diff($files, array('.', '..', 'thumbs'));
        
        $images = array();
                
        foreach ($files as $file) {
            $images []= array (
                'url' => $this->gallery_path_url . $file,
                'thumb_url' => $this->gallery_path_url . 'thumbs/' . $file
            );
        }
        
        return $images;
    }
    
}

I need help.
Thank you.
#2

[eluser]SimonH[/eluser]
Hi,

I am not sure whether this could be any solution to your problem, however I have noticed that you have an gallery_path class member that is set to APPPATH . '../images'. The problem here is that you should use an absolute path which represents the path to that particular folder on the server (eg. C:/wamp/htdocs/my_project/images/). Something that I tend to do is create a config var in the config.php file called base_path and assign it the correct value (eg. C:/wamp/htdocs/my_project/) this way I can reuse this later using $this->config->item('base_path').

Hope this helps.




Theme © iAndrew 2016 - Forum software by © MyBB