$size = getimagesize($filename); //Get mime information
$fp=fopen($filename, "rb"); //Open the file in binary mode
if ($size && $fp) {
header("Content-type: {$size['mime']}");
fpassthru($fp); // Output to browser
exit;
} else {
// error
}
?>
Copy code
The amount of code is less than 1/10 of the original, and the speed is N times faster.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn