Welcome Guest, Not a member yet? Register   Sign In
Is there any way to download a image when it is clicked?
#4

[eluser]cereal[/eluser]
Or you can create a controller "download" like this:

Code:
<?php

class Download extends Controller {

    function Download()
    {
        parent::Controller();
        $this->load->helper(array('url', 'download'));
    }
    
    function image()
    {
        @ob_end_clean();
    $data = file_get_contents($this->input->server('DOCUMENT_ROOT') . 'images/' . $this->uri->segment(3));
        $name = $this->uri->segment(3);
        force_download($name, $data);
    }
}
?>

To download just call: http://your.server/download/image/name_of_file.jpg

This way you can add a session check to prevent direct linking, keep track of downloads, you can hide the real path and you can use an .htaccess file to prevent downloads from the images/ directory. Bye Smile


Messages In This Thread
Is there any way to download a image when it is clicked? - by El Forum - 12-24-2010, 06:06 AM



Theme © iAndrew 2016 - Forum software by © MyBB