Are you sure you want to laugh at me and say "download files" in a simple way? Of course it is not as simple as you think. For example, if you want to see that the customer needs to fill out a form to download a file, your first idea must be to use the "Redirect" method first.
Are you sure you want to laugh at me and say "download files" in a simple way? Of course it is not as simple as you think. For example, if you want to see that the customer needs to fill out a form to download a file, your first thought must be "Redirect, first, check whether the form is complete and complete, and then point the website to this file, so that the customer can download it. for example, the following code written by the author:
<?
// Check whether all FORM fields are complete...
If ($ form_completed ){
Header ('Location: http://www.webjx.com/download/info_check.exe ');
Exit;
}
?>
Or the following situations:
"<A href = 'http: // www.yourwebl.com/users/download.php? Id = 124524 '> start file download </a>"
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 the security title, you do not want users to copy the website directly 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 label
Header ('content-type: application/octet-stream ');
Header ('Accept-Ranges: bytes ');
Header ('Accept-Length: '. filesize ($ file_dir. $ file_name ));
Header ('content-Disposition: attachment; filename = '. $ file_name );
// Output file content
Echo fread ($ file, filesize ($ file_dir. $ file_name ));
Fclose ($ file );
Exit ;}
?>
If the file path is an "http" or "ftp" URL, the source code may change a little. The program is as follows:
<?
$ File_name = 'info_check.exe ';
$ File_dir = 'http: // www.webjx.com /';
$ File = @ fopen ($ file_dir. $ file_name, 'r ');
If (! $ File ){
Echo 'file not found ';
} Else {
Header ('content-type: application/octet-stream ');
Header ('content-Disposition: attachment; filename = '. $ file_name );
While (! Feof ($ file )){
Echo fread ($ file, 50000 );
}
Fclose ($ file );
}
?>
In this way, you can use PHP to directly output files.