Jump to content

unlink() image


dreamwest

Recommended Posts

PHP just sends the HTML to the browser, it doesn't interpret the HTML, so it doesn't load the image. That's the job of the browser. So the reason it's not working is because by the time the browser tries to load the image (the php script has already sent the output and stopped executing) the image was unlinked and does no exist anymore.

Link to comment
https://forums.phpfreaks.com/topic/182229-unlink-image/#findComment-961630
Share on other sites

PHP just sends the HTML to the browser, it doesn't interpret the HTML, so it doesn't load the image. That's the job of the browser. So the reason it's not working is because by the time the browser tries to load the image (the php script has already send the output and stopped executing) the image was unlinked and does no exist anymore.

 

Is there a way around this?

Link to comment
https://forums.phpfreaks.com/topic/182229-unlink-image/#findComment-961632
Share on other sites

To go along with what AlexWD said, one way to do it is create a script that spits out an image. the gist of it, readfile the image into a string, after that unlink the imagefile then use php to send the right headers and display the image to the browser.

 

So instead of

 

<img src="image.jpg" />

 

It would be

<img src="yourimagescript.php?name=imagename.jpg" />

 

If you need a better example let me know, I am bored enough to write some code.

Link to comment
https://forums.phpfreaks.com/topic/182229-unlink-image/#findComment-961638
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.