here is how to use PHP to implement the file download program, mainly for the convenience of their own search, but also for the convenience of people to access to learn (of course, there are other similar code on the Internet). The detailed analysis of the original program comments.
PHP implementation file Download program:
FileDownService.class.php
10*1024*1024) {echo ""; return;} *///4. Add HTTP response information//return the file header ("Content-type:application/octet-stream");//return header by byte size ("Accept-ranges:bytes ");//Returns the file size header (" Accept-length: ". $file _size);//The Client's popup dialog box, corresponding to the filename header (" content-disposition:attachment; Filename= ". $file _name);//5. Send the data back to the client $buffer=1024;//in order to download the security, we'd better make a file byte read counter $file_count=0;//This sentence is used to determine whether the file ends while (! Feof ($fp) && $file _size-$file _count>0) {$file _data=fread ($fp, $buffer);//Statistics read the number of bytes $file_count+= $buffer ;//Send some data back to the browser echo $file _data;} 6. Close file fclose ($fp);}? >
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
The above describes the use of PHP to implement file download, including aspects of the content, I hope that the PHP tutorial interested in a friend helpful.