PHP files are directly output and downloaded. Are you sure you want to laugh at the fact that I downloaded files so easily? Of course it is not as simple as you think. For example, if you want the customer to fill out a form before downloading a certain file, you will surely laugh at me and say "downloading files" in a simple way? Of course it is not as simple as you think. For example, if you want the customer to fill out a form before downloading a file, your first thought must be "Redirect, check whether the form is complete and complete. then, point the website address to the file so that the customer can download the file. for example, the following code is compiled by the author:
// Check whether all FORM fields are complete...
If ($ form_completed ){
Header ("Location: http://www.etoow.com/download/info_check.exe ");
Exit;
}
?>
Or the following situations:
"Start file download"
The ID method is used to receive the number of the file to be downloaded, and then the "Redirect" method is used to connect to the actual website.
If you want to create an e-commerce website for "online shopping" and consider security issues, you do not want users to directly copy the website to download the file, I suggest you use PHP to directly read the actual file and then download it. The procedure is as follows:
$ File_name = "info_check.exe ";
$ File_dir = "/public/www/download /";
If (! File_exists ($ file_dir. $ file_name) {// check whether the file exists
Echo "file not found ";
Exit;
} Else {
$ File = fopen ($ file_dir. $ file_name, "r"); // open the file
// Input file tag
Header ("Content-type: application/octet-stream ");
Header ("Accept-Ranges: bytes ");
Why? Of course it is not as simple as you think. For example, you want the customer to fill out a form before downloading a file...