title: check if files exists and provides a link to it php
body: <p>I want to check if a directory contains a specific file(any type, image, pdf etc.) or not. If it contains the file, I want to provide a download link for this file, otherwise print <code>"not exist"</code>. Unfortunately, my code is printing <code>not exist</code> all the time even if the file exists in the directory. Here is my code:</p>
  
  <pre><code>                &lt;td&gt;  &lt;?php
  
  if (file_exists('plans/'.$RID)) {
    echo"&lt;a href='plans/$RID'&gt;Plan&lt;/a&gt;";
  } else {
      echo "not exists";
  }
  ?&gt;  &lt;/td&gt;
  </code></pre>
  
  <p>here is another code I also tried it but doesn't work:</p>
  
  <pre><code>&lt;td&gt;  &lt;?php
      $plan= 'plans/'.$RID;
      if (file_exists($plan)) {
        echo"&lt;a href='plans/$RID'&gt;Plan&lt;/a&gt;";
      } else {
          echo "not exists";
      }
      ?&gt;  &lt;/td&gt;
  </code></pre>