27
In order to have the administration of a website to be performed from a server other than the one where the website is hosted, the problem of dealing with remote images has arisen.
Common problems:
- Check if the image actually exists before linking to it;
- When replacing a particular image, check if the previous one exists to be deleted;
- Check that the image uploaded to the server is not named after an existing image.
Normally, this type of operations is carried out with the is_file()
, but as it does not support URL, only absolute or relative paths of the server itself, it is thus impossible for this scenario.
Question
Using PHP, how can I check if a remote image exists?
Check if there is an image, or if there is a file? This changes the answer a lot. In the file question, it was answered, in the same picture question, "came close". (there may be a file in the place that is not image)
– Bacco