This article mainly introduces the method of forced downloading of files or pictures in PHP, and implements simple reading and output related operation skills of files or pictures through custom functions. Friends in need can refer to the following
for details As follows:
//下载 function downregcaseAction() { $file="upload/regcase.jpg"; if(isfile($file)) { header("Content-Type: application/force-download"); header("Content-Disposition: attachment; filename=".basename(file)); readfile(file); exit; } else { echo "文件不存在!"; exit; } }
The above is the entire content of this article, I hope it will be helpful to everyone's study.
Related recommendations: Examples of PDO transaction processing operations in
PHPHow to automatically load classes in
##PHPSimple method of parsing xml into an array
The above is the detailed content of How to implement forced downloading of files or images in php. For more information, please follow other related articles on the PHP Chinese website!