Now we are going to learn how to download a file from directory or server in PHP. To download a file in PHP, you want to force the browser to download the file without for display. Working with header() and readfile() function, you can simply download a file in PHP. Here we’ll give the example PHP code to force download file in PHP. Moreover, this simple PHP script helps to implement a download link that downloads a file from the directory. The bellow example can be used for download all the types of file like pdf, text, doc, zip, images, exe files, etc.