0

I'm trying to do a process like this:

  1. Generate a temporary image using PHP
  2. Generate/Send HTML to browser, for displaying some misc info and display the generated image
  3. flush();
  4. Wait (sleep();) 10 seconds (so browser has some time to load the image)
  5. Delete the temporary image from server

It in fact "almost" works... only problem is that browser keeps on its "loading" state for the other 10 seconds I gave the script to delete the image... like if needs some "signal" to effectively "acknowledge" the page load as "complete". My question is, how to properly do this? :P

Nikolay Kostov
  • 16,433
  • 23
  • 85
  • 123
Hcktrox
  • 1
  • 1
  • The page doesn't finish loading until the server closes the connection. – Barmar Apr 14 '15 at 12:57
  • Until the script exits, the browser has to keep loading in case it sends more HTML. – Barmar Apr 14 '15 at 12:59
  • Instead of doing it this way, why don't you run a `cron` job that periodically deletes old image files. Or send the image with inline data: http://stackoverflow.com/questions/1207190/embedding-base64-images – Barmar Apr 14 '15 at 13:00

0 Answers0