This article mainly introduces the PHP implementation file Download Simple example, the need for friends can refer to the following
The code is as follows: Public function downloads ($name) {$name _tmp = explode ("_", $name); $type = $name _tmp[0]; $file _time = Explode (".", $ NAME_TMP[3]); $file _time = $file _time[0]; $file _date = Date ("Y/md", $file _time); $file _dir = Site_path. " /data/uploads/$type/$file _date/"; if (!file_exists ($file _dir. $name)) {header ("content-type:text/html; Charset=utf-8 "); echo "File not found!"; Exit } else {$file = fopen ($file _dir. $name, "R"); Header ("Content-type:application/octet-stream"); Header ("Accept-ranges:bytes"); Header ("Accept-length:". FileSize ($file _dir. $name)); Header ("content-disposition:attachment; Filename= ". $name); Echo fread ($file, FileSize ($file _dir. $name)); Fclose ($file);}} Example 2: Code implementation file Download general implementation download is called URL to download, but encountered IE can recognize open files can not be used in this way, such as downloading a picture, HTML page, etc., then need to be programmed to implement, the following PHP code can be resolved: The code is as follows:
http://www.bkjia.com/PHPjc/739908.html www.bkjia.com true http://www.bkjia.com/PHPjc/739908.html techarticle This article mainly introduces the PHP implementation file Download Simple example, the need for friends can refer to the following code: Public Function Downloads ($name) {$name _tmp = explode (_, $name); $type = $ Name ...