CodeIgniter Forums

Full Version: File download help required
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[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.

El Forum

[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);
        }

El Forum

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

El Forum

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

El Forum

[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