Home >Backend Development >PHP Tutorial >PHP code to extract an image file and display it on the browser

PHP code to extract an image file and display it on the browser

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-25 09:03:24986browse
  1. $size = getimagesize($filename); //Get mime information
  2. $fp=fopen($filename, "rb"); //Open the file in binary mode
  3. if ($size && $fp) {
  4. header("Content-type: {$size['mime']}");
  5. fpassthru($fp); // Output to browser
  6. exit;
  7. } else {
  8. // error
  9. }
  10. ?>
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