File download statistics PHP programming _php Tutorial

Source: Internet
Author: User
Now there are many Web download files provide statistical features, this article discusses how to use PHP to implement this function, for the need to hide the download file path, avoid users directly using URL download programmer, this article also has some reference value. Implementation environment: LINUX+APACHE+PHP+MYSQLWINDOWS98+PWS4+PHP+MYSQL a database structure database to create a table to store file information, including file encoding, name, download path, statistics, The corresponding SQL file contents are as follows: CREATE DATABASE dl_db; CREATE TABLE dl_file (ID varchar (6), name varchar (), URL varchar ($), count bigint (+)); INSERT into Dl_file VALUES (00 0001, test, Test.zip, 0), INSERT into Dl_file VALUES (000002, TIF, download/123.tif, 0), PHP programming 1, function file function file including database connection initialization function and cue letter Display functions. DL_FUNC.PHP3: 2. Download Connection page The download Connection page reads the download file information from the database and displays it. FILELIST.PHP3: <title>File download</title> "; echo "$arr _dlfile[name]"; echo ""; echo "(Download count: $arr _dlfile[count])"; echo "

";} Mysql_close ($dl _in);? >3. Download page when the file is present, the download page goes to the file to be downloaded, and if an error occurs, a prompt is displayed. FILEDOWN.PHP3: The principle of implementation is to show the connection of all files, and then to get the name and path of the file according to the Filelist.php3 ID, and to download the file by repositioning. The above procedure the author tested, run normally. The file URL can be local, or it can be on a different server. If the contents of the file are stored in the database, or if the file is not in the HTTP and FTP path, the solution can be used to echo the contents of the file to replace the header ("Location: $arrfile [url]"), because the method of reading the file is relatively simple, not to repeat here.

http://www.bkjia.com/PHPjc/532037.html www.bkjia.com true http://www.bkjia.com/PHPjc/532037.html techarticle now there are many Web download files provide statistical features, this article discusses how to use PHP to implement this feature, for want to hide the download file path, to avoid the user directly using the URL to download ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.