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.