In order to be able to administer a website from a server other than the one on which the website is hosted, the problem of dealing with remote images has arisen.
Common problems:
- Verify that the image actually exists before creating links to it;
- When replacing a particular image, check if the previous image exists to be deleted;
- Verify that the image uploaded to the server does not have the same name as an existing image.
Typically, this type of operation is done with is_file()
, but since it does not support URLs, only absolute or relative paths of the server itself, it is therefore unfeasible for this scenario.
Question
Using PHP, how can I check if a remote image exists?