Simple page download file using php and jquery

If you want to hide the download links at the same time requires users to wait 5 seconds or more (depending on you). Users can download a file via a php script to hide the real path, web address or URL to that file. many sites today use a download manager such way. This article will show you how to create a script to download it on your website.

php file download script

To do page download file you need to follow these steps ?
First we create three folders: contain_folder, include, and css

In the folder: include

– config.php: First line enter the name of the directory to upload files UPLOAD_DIR. here I enter the folder name is “contain_folder”. Second line enter the random string SECURITY_CODE.

– function.php: includes of two functions is makeHash() used to create the download url and verifyHash() is used to check the hash of the url.


In the folder: contain_folder (Folder in your web server that contains the content to be downloaded)

– .htaccess: inside this protected folder containing the content for downloading , it prevent direct file downloading and any forms of hot linking

First check if mod_access in installed to apache, then add the following to your .htaccess


In root folder: the root directory of your website

– x.php: check the hash is created from the function.php file in the folder include and return url download

– .htaccess: add RewriteRule to file .htaccess

– download.php The page where you will need to show the download link should execute a PHP script or have a .php extension. You can create download link as below:

PHP download code:

 HTML download file code


Here I show information iP visitors

HTML jquery code

The following code will give the download can not detect the folder containing the file to be downloaded. and wait 5 seconds to show the download file links. or you can also count the number of downloads of using mysql database, file size, ip, etc…

Place all three PHP scripts and the .zip file into the same directory on your server and Change the file permission of the directory to 644. Hope that this will help you.


  1. Posted by Egypt

Add Your Comment