I have a PHP script that generates images. At this moment with every request PHP creates a temporary directory and fills it with the created images, then it sends the links to JS, which displays them in the browser in a special order.
Is there any way to pass these images directly from PHP to JS without a temporary directory?
I don't want to use temporary directories because it takes space and resources of server and I have to check that images download has been completed before deleting them.
I am thinking on using Json encoding and decoding but I don't like this because it's time consuming.
Is there another way to send images directly from PHP to JS?
There is a way to work with using src to php script with headers: Using PHP to send a certain image or How to generate image file using this PHP function?
But this I could only work with one image per request. I mean - if I have 5 or 6 divs with images I have to make 5 or 6 requests from JS to my php script. Is there a way to send multiple images from PHP to JS?