file explorer and force_download - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: file explorer and force_download (/showthread.php?tid=26689) |
file explorer and force_download - El Forum - 01-20-2010 [eluser]peter222[/eluser] I just listed files from my directory and want to add anchor to all of them. I want to use force_download to download this files but don't know how to send path info to download function. For example: file: Code: /home/myprofile/uploads/pict1.jpg anchor: Code: <a href="<?=base_url()?>/download/index/[here_path_and_file]">pict1.jpg</a> This way will not work, so how to use force_download here? I know that I can put any random data to database when upload file and do it this way: database record: Code: path: /home/myprofile/uploads/ anchor: Code: <a href="<?=base_url()?>/download/index/23f3b4c5df6ce6cc6434565759826734">pict1.jpg</a> but is it only this way possible? I realy need database to realise it? file explorer and force_download - El Forum - 01-20-2010 [eluser]danmontgomery[/eluser] http://ellislab.com/codeigniter/user-guide/helpers/download_helper.html Quote:force_download('filename', 'data') file explorer and force_download - El Forum - 01-21-2010 [eluser]peter222[/eluser] I know this help, but my question is, how can i send info about path and file to my function, maybe I don't understand something but I can't do it this way: Code: <a href="<?=base_url()?>/download_controller/download_function/[path_and_file]">pict1.jpg</a> file explorer and force_download - El Forum - 01-21-2010 [eluser]Jan_1[/eluser] for example: view: Code: echo anchor('controller/download/folder/filename', 'title="pict1.jpg"'); Code: $path = $this->uri->segment(2); file explorer and force_download - El Forum - 01-21-2010 [eluser]peter222[/eluser] OK I understand now. I couldn't imagine how to handle subdirectories in this case because every subdirectory mean another function argument in URL. But I found uri_string() in url helper so it will be easy to get full path now. Thank You for help! file explorer and force_download - El Forum - 01-21-2010 [eluser]peter222[/eluser] Finally my working index function in download controller looks like this: example link: Code: <a href="http://mysite.com/download/index/folder/subfolder/subfolder/strangefilename@#$.jpg">strangefilename@#$.jpg</a> index function code: Code: $data = file_get_contents(rtrim($this->config->item('myuploadfolder'), '/').str_replace("download/index/","",rawurldecode(uri_string()))); |