Welcome Guest, Not a member yet? Register   Sign In
Image force_download problem
#1

[eluser]veledrom[/eluser]
Hi,

I can upload and download the image but when I open downloaded image, nothing shows up. It says "no preview". However, I can access the image through browser by typing the path.
Code:
public function do_downloadfile()
    {
        $exist = @fopen(base_url() . 'upload/' . $this->uri->segment(3), "r");
    
        if($exist)
        {
            $this->load->helper('download');
            
            //$filepath = './upload/' . $this->uri->segment(3);
            $filepath = base_url() . 'upload/' . $this->uri->segment(3);
            
            //$data = file_get_contents($filepath);
            $data = fopen($filepath, "wb");
            $name = $this->uri->segment(3);
            
            force_download($name, $exist);
        }
        else
        {
            echo $this->uri->segment(3) . " doesn't exist!";
        }
    }


Upload folder is under main root.
http://localhost/CI/upload/12743552b2871...5dd6fe.JPG

Is file being corrupted when downloaded? Neither fopen() nor file_get_contest() work...

Thanks


Messages In This Thread
Image force_download problem - by El Forum - 05-26-2011, 10:44 AM
Image force_download problem - by El Forum - 05-26-2011, 10:50 PM
Image force_download problem - by El Forum - 05-27-2011, 01:36 AM
Image force_download problem - by El Forum - 05-27-2011, 02:49 AM
Image force_download problem - by El Forum - 05-27-2011, 03:58 AM



Theme © iAndrew 2016 - Forum software by © MyBB