Answers.Body: <p><code>IOHelper::fileExists()</code> will return false for a few reasons:</p>
  
  <ol>
  <li><p>Either PHP's <a href="https://secure.php.net/manual/en/function.realpath.php" rel="nofollow noreferrer">realpath</a> or <a href="https://secure.php.net/manual/en/function.is-file.php" rel="nofollow noreferrer">is_file</a> returns false. i.e. the given path doesn't exist or PHP doesn't have executable permissions on the folders leading up to that path or read permissions on the file itself.</p></li>
  <li><p>You're using a case-sensitive file system and you're passing in a different cased path/filename than what's on the file system.</p></li>
  </ol>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-08T17:05:21.717Z
Answers.LastActivityDate: 2017-09-08T17:05:21.717Z
Answers.UserDisplayName: Brad Bell
Body: <p>I use the following code:</p>
  
  <pre><code>$sourcePath = $assetRecord-&gt;source-&gt;sourceType-&gt;getBasePath();
  $folderPath = $assetRecord-&gt;getFolder()-&gt;path;
  $path = $sourcePath.$folderPath.$assetRecord-&gt;filename;
  
  if (IOHelper::fileExists($path)) {
      $content = IOHelper::getFileContents($assetRecord-&gt;url);
      craft()-&gt;request-&gt;sendFile($test, $content, array('forceDownload' =&gt; true));
  }
  </code></pre>
  
  <p>The fileExists always return false. I use the image all over the site without any problems. Also the <code>$path</code> variable return normal path from inside the public folder.</p>
  
  <p>This code lives inside a custom plugin.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-09-08T15:33:45.070Z
Comments.Text: What is the question?
Comments.UserDisplayName: Lindsey D
Tags: <plugin-development>
Title: IOHelper::fileExists always false
ThreadText: # IOHelper::fileExists always false
  
  (Asked by: username_0 on 2017-09-08)
  
  I use the following code:
  
  ```
  $sourcePath = $assetRecord->source->sourceType->getBasePath();
  $folderPath = $assetRecord->getFolder()->path;
  $path = $sourcePath.$folderPath.$assetRecord->filename;
  
  if (IOHelper::fileExists($path)) {
      $content = IOHelper::getFileContents($assetRecord->url);
      craft()->request->sendFile($test, $content, array('forceDownload' => true));
  }
  
  ```
  
  The fileExists always return false. I use the image all over the site without any problems. Also the `$path` variable return normal path from inside the public folder.
  
  This code lives inside a custom plugin.
  
  **Tags:** plugin-development
  
  > **Comments:**
  > **username_1**: What is the question?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2017-09-08. Score: 1
  
  `IOHelper::fileExists()` will return false for a few reasons:
  
  1. Either PHP's [realpath](https://secure.php.net/manual/en/function.realpath.php) or [is\_file](https://secure.php.net/manual/en/function.is-file.php) returns false. i.e. the given path doesn't exist or PHP doesn't have executable permissions on the folders leading up to that path or read permissions on the file itself.
  2. You're using a case-sensitive file system and you're passing in a different cased path/filename than what's on the file system.
  
  
  ---
  
  