Welcome Guest, Not a member yet? Register   Sign In
Image resizing locks the image
#1

[eluser]@li[/eluser]
Hi,

I have some code on my website which lets a user upload their image (using the CI upload library), then attempts to resize it (using the CI image manipulation library). However after resizing, the image seems to get locked, if I try to download/view it (on my website) it says permission denied, you can't access this image, etc.

This works fine on my localhost (a windows XP machine using WAMP) but on the website which is probably a linux server, it seems to lock the image after resizing it.

Has anyone experienced this or has any ideas?

Here's my code in case it helps:

Code:
$config['upload_path'] = $dir;
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size']    = '2000';
        $config['encrypt_name']    = true;
        
        $this->load->library('upload', $config);
        
        if (! $this->upload->do_upload('pic'))
        {
            $this->upload_err=$this->upload->display_errors();
            $this->index();
            return false;
        }
            extract($this->upload->data());
                if ($image_height > $height_allowed || $image_width > $width_allowed)
        {    
            unset($config);
            
            $config['image_library'] = 'gd';
            $config['source_image']    = $full_path;
            $config['create_thumb'] = false;
            $config['maintain_ratio'] = TRUE;
            $config['width']     = $width;
            $config['height']    = $height;
            
            $this->load->library('image_lib', $config);
            
            $this->image_lib->resize();
        }
#2

[eluser]@li[/eluser]
This is the exact error I got:
Quote:550 e5794a9133b2d1184aa775eda25cbe3a.JPG: Permission denied : /httpdocs/uploads/e5794a9133b2d1184aa775eda25cbe3a.JPG
#3

[eluser]ray73864[/eluser]
not to be a bit on the silly side, but Windows doesn't have the permission things like Linux does, the reason it works on WinXP with WAMP is because Windows lets it work, everyone is assumed to have full access to the file for reading purposes.

The reason it doesn't work on the linux box is likely because of you not having enough permissions to read that file, basically the /httpdocs/uploads directory (if that's where you are really going to read it from) should have atleast 'read' access for everyone, so, 444, but the server still needs to be able to upload to it, so people tend to just set a directly like that as 777 (although 774 should still work fine since it is only stopping the world from writing to the directory and not the webserver).

Ray
#4

[eluser]@li[/eluser]
I figured out what was the problem, thanks all!




Theme © iAndrew 2016 - Forum software by © MyBB