Downloading Files in CakePHP

This is the continuation for Uploading Multiple Files in CakePHP. This lesson covers downloading of files being uploaded to your server. All we have to do is add the custom function below in your AttachmentsController.

The parameter will the function what file will be downloaded. Inside the function just add the script below. Just read the comments for to further understand it.

That’s it, you can now modify your Attachments.ctp table. Adding link to the filename you want to download by specifying the controller, action and also the parameter.

 

Sharing is caring!