PHP Function To Download A File

In this tutorial i will described you how to download a file using php.Normally when we click the download link the download window is open and ask to user,do you want to save or Open file.I have created a DownloadFile($fileName) php method which will take file name as a parameters. In first we will check file is exist or not if yes then we will check file extension of file name,Now we will set Content-Type of the file according to its file type.

How to call function:

Download Code and Demo Link