Problems encountered when reading images using the readfile function

Source: Internet
Author: User
When reading images using the readfile function, I plan to display images on a page, instead of directly providing the scr of img, but input by a readfile function, which is equivalent to reading images and outputting them by the server. the front-end page is as follows: & lt; imgsrc & quot; mywebsite. comgetobj1.php? Pathwww.abc.comimages11.jpg & quot; & q problems encountered when reading images using the readfile function
I plan to display images on a page, instead of directly providing the scr of img, but input by a readfile function, which is equivalent to reading images and then outputting them by the server.
The front-end page is as follows:



...



The getobj1.php code in the background is as follows:
Header ('content-Type: image/jpeg ');
Readfile ($ _ GET ["path"]);
?>

The problem is as follows:
Images can be displayed normally and are indeed read by the server (because some images cannot be accessed directly .. GFW)
However, these images are displayed one by one, rather than all normally accessed images.
Is there any way to solve this problem? is it a problem with the image server or with the PHP mechanism?
Please help

------ Solution --------------------
It should be a code issue. The author can consider the cache to read the cache at a time and then output the data.
Ob_start
· // Process operations such as reading and displaying images
Ob_flush ();
Flush ();

------ Solution --------------------
This is normal
Because the image is not on your server, it is read remotely and then sent to the client.
Your server is just a transit
Since there is an additional tier of transit, of course it is slow,

There is a solution
Yes,
You can create a cache directory.
When you encounter a request, check whether the server cache contains,
If no, this request is the first time, the remote image is stored on the server.
If yes, directly send the server to the client

In this way, each image only needs to be transferred once.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.