Answers.Body: <p>Using PHP's <code>file_exists</code> function is perfectly fine for checking this.</p>
  <pre class="lang-php prettyprint-override"><code>$exists = file_exists($path);
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-07-26T07:57:17.333Z
Answers.LastActivityDate: 2022-07-26T07:57:17.333Z
Answers.UserDisplayName: Ben Croker
Body: <p>If I have an asset resource, loaded successfully from the database, whose corresponding file no longer exists on its Volume (irrespective of Volume type), what is the best way to find out if the file exists, in PHP?</p>
  <p><code>file_exists</code> or maybe <code>is_file</code>?</p>
  <p>Or is there an inbuilt method in Craft I should be using?</p>
  <p>Any help appreciated!</p>
  
Tags: <plugin-development><assets><php>
Title: What's the correct way to check that an asset file exists?
ThreadText: # What's the correct way to check that an asset file exists?
  
  (Asked by: username_0 on 2022-04-13)
  
  If I have an asset resource, loaded successfully from the database, whose corresponding file no longer exists on its Volume (irrespective of Volume type), what is the best way to find out if the file exists, in PHP?
  
  `file_exists` or maybe `is_file`?
  
  Or is there an inbuilt method in Craft I should be using?
  
  Any help appreciated!
  
  **Tags:** plugin-development, assets, php
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-07-26. Score: 2
  
  Using PHP's `file_exists` function is perfectly fine for checking this.
  
  ```php
  $exists = file_exists($path);
  
  ```
  
  
  ---
  
  