Many download files on websites now provide statistical functions. This article describes how to use php to implement this function. programmers who want to hide the download file path and avoid using the url to download files directly, this article also has some reference value. Implementation environment: Linux + Apache + Php + MysqlWindows98 + PWS4 + Php + MySyntaxHigh
Many download files on websites now provide statistical functions. This article describes how to use php to implement this function. programmers who want to hide the download file path and avoid using the url to download files directly, this article also has some reference value. Implementation environment: Linux + Apache + Php + MysqlWindows98 + PWS4 + Php + Mysql I. create a table in the database structure database to store file information, including file encoding, name, download path, and statistics. the corresponding SQL file content is as follows: CREATE DATABASE dl_db; CREATE TABLE dl_file (id varchar (6), name varchar (50 ), url varchar (200), count bigint (10); insert into dl_file VALUES (000001, test, test.zip, 0); insert into dl_file VALUES (000002, tif, download/123.tif, 0); 2. php Programming 1. function files include database connection initialization functions and prompt information display functions. Dl_func.php3: 2. download connection page read the downloaded file information from the database and display it. Filelist. php3:File Download "; Echo" $ arr_dlfile [name] "; echo" "; echo" (downloads: $ arr_dlfile [count]) "; echo"
";} Mysql_close ($ dl_in);?>3. when a file exists on the download page, go to the file to be downloaded. If an error occurs, a prompt is displayed. Filedown. php3: The principle is that filelist. php3 displays the connections of all files, obtains the name and path of the file based on the passed id, and downloads the file through location. The above procedures have been tested and run properly. The file url can be local or on another server. If the file content is stored in the database, or the file is not in the http or ftp path, you can echo the file content to replace the header ("location: $ arrfile [url] "), because the method for reading files is relatively simple, we will not repeat it here.