CodeIgniter Forums
File download help required - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: File download help required (/thread-9396.html)



File download help required - El Forum - 06-24-2008

[eluser]Computerzworld[/eluser]
Hello. I am using CI download helper for downloading the file from the server. What I want is to download the file by clicking on the download link. I have written the code like for downloading the file like this in my controller.
Code:
function forceDownload()
    {
        $this->load->helper('download');
        $data = file_get_contents(base_url().'/uploads/files/admin_uploadedFile'); // Read the file's contents
        $name = $this->fileName;        

        force_download($name, $data);
        }

and I am calling this function on click event of download link. In js I am using redirection to go to this function.

But instead of download it redirects me to the folder on the server where all files are located. I got stuck at this point. Please help me. Thanks in advance.


File download help required - El Forum - 06-24-2008

[eluser]Computerzworld[/eluser]
I have slightly changed my code and now I am getting file contents in new window. But the file doesn't download. Here is the modifictation that I have made.
Code:
function forceDownload()
    {
        $this->load->helper('download');
        $data = file_get_contents(base_url().'/uploads/files/admin_uploadedFile/'.$this->fileName); //<-- change in code
        $name = $this->fileName;        

        force_download($name, $data);
        }



File download help required - El Forum - 06-24-2008

[eluser]Yash[/eluser]
tell me your AIM ..


File download help required - El Forum - 06-24-2008

[eluser]Computerzworld[/eluser]
what exactly I want is to download file from the server by clicking on the download link.


File download help required - El Forum - 09-24-2008

[eluser]abedzilla[/eluser]
i have the same problem with Computerzworld
the file won't begin the download process, it just keep displaying a blank page