Question

check if images exist on spaces

How do I check if img exists in the spaces bucket please? in php


Submit an answer
Answer a question...

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

alexdo
Site Moderator
Site Moderator badge
October 12, 2022

Hello @7af277694b14-47f6-9728-30c4a5

In your PHP application, you can use the file_exists function

Basic examples are

  1. if(file_exists($path_to_file)){
  2. // other stuff
  3. }
<?php
$filename = '/path/to/foo.txt';

if (file_exists($filename)) {
    echo "The file $filename exists";
} else {
    echo "The file $filename does not exist";
}
?>

Hope that this helps!