I have a method in my controller
public function download($filepath){
$download_path = $_SERVER['DOCUMENT_ROOT']. "mediabox/import";
$file = $download_path + $filepath ;
if(!$file) die("I'm sorry, you must specify a file name to download.");
if(eregi("\.ht.+", $file)) die("I'm sorry, you may not download that file.");
if(!file_exists($file)) die("I'm sorry, the file doesn't seem to exist.");
$type = filetype($file);
header("Content-type: $type");
header("Content-Disposition: attachment;filename=$filename");
header('Pragma: no-cache');
header('Expires: 0');
// Send the file contents.
readfile($file);
}
In my view I have a link
<a target='_blank' class='download_dialog' onClick="???">
I want to call the download metho of my controller onclick event of the link .
Is it good to do so ?
How can I do it ?
Thanks
You could try:
(and yes, you would need to be using the url helper for base_url) or use that url in some javascript onClick call, but I am unsure if this is the best solution for you.