This example describes a simple way to implement a forced download of a file or picture in PHP. Share to everyone for your reference, specific as follows:
Download
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 file does not exist! ";
Exit;
}
}
More about PHP Interested readers can view the site topics: "PHP file Operation Summary", "PHP graphics and pictures Operating skills summary", "PHP Array" operation Skills Encyclopedia, "PHP Basic Grammar Introductory Course", "PHP Operations and Operator Usage Summary", " Introduction to PHP object-oriented programming program, "PHP Network Programming Skills Summary", "PHP string (String) Usage Summary", "Php+mysql database Operation Tutorial" and "PHP common database Operation Skills Summary"
I hope this article will help you with the PHP program design.