Nowadays, many sites provide statistical functions for downloading files. This article discusses how to use PHP to implement this function. This article also has certain reference value for programmers who want to hide the download file path and prevent users from directly using URL downloads. Implementation environment: Linux+Apache+Php+MysqlWindows98+PWS4+Php+Mysql 1. Database structure Create a table in the 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 file The function file includes the database connection initialization function and the prompt information display function. dl_func.php3: //初始化数据库连接的程序function dl_dbconnect(){ error_reporting(1+4); //禁掉warning性错误 $dl_in=0; $dl_in=mysql_connect("localhost:3306","root","123456"); if(!dl_in) { //如果连接失败,退出 echo "数据库无法连接"; exit; } mysql_select_db("dl_db",$dl_in); return $dl_in; } //显示提示信息的函数 function infopage($strInfo){ echo ""; }?> 2. Download connection page The download connection page reads the download file information from the database and displays it. filelist.php3:
Garbled characters starting with ^quxjg$c
statistical analysis
How to open img file
You need permission from admin to make changes to this file
What format is doc?
How to open php file
How to solve the problem that Apple cannot download more than 200 files
How to remove the first few elements of an array in php