phpcodeigniterforce-download

Can I define a folder where to download to, using force_download()?


I'd need to define a folder where a downloaded files is placed.

Is it possible to achieve a download into a specific folder using the force_download() function, of Codeigniter's framework?


Solution

  • force_download() is part of CI download helper

    Generates server headers which force data to be downloaded to your desktop. Useful with file downloads. The first parameter is the name you want the downloaded file to be named, the second parameter is the file data.

    that said, a file will be downloaded to your designated download folder, wherever that is on your local disk. You can use this approach to make files downloadable for any user

    what you are looking for is to use the CI FTP Class:

    Downloads a file from your server. You must supply the remote path and the local path, and you can optionally set the mode. Example:

    $this->ftp->download('/public_html/myfile.html', '/local/path/to/myfile.html', 'ascii');
    

    you must make sure that each time you call this to have the user supplying you with a valid local path, where the downloaded files will be stored.