Skip to content
Advertisement

how can I download my file residing in local repository

I am new to CodeIgniter and was working on downloading a file. However, I want to download a file that resides on my local machine, I am able to locate the file by providing the path, also the file gets downloaded with a File type, However, I want my file to be in .csv format

Here goes my Controller’s download function:

JavaScript

Where am I going wrong?

Advertisement

Answer

The force_download() takes in two parameters, i.e. the file name and the data to be written to that file. As the file already consists of some sample data, therefore, the function goes like this:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement