Welcome Guest, Not a member yet? Register   Sign In
File download help required
#1

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

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

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

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

[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




Theme © iAndrew 2016 - Forum software by © MyBB