Quantcast
Channel: Developer Feed - Snippet
Viewing all articles
Browse latest Browse all 178

How to check if file exists in PHP?

$
0
0

Snippet
Using the file_exists function it is very easy to check whether a file exists in a given directory or not. Say we want to check if file name audio.mp3 exists or not in /tmp folder.

  1. <?php
  2. $filename='/tmp/audio.mp3';
  3.  
  4. if(file_exists($filename)){
  5. echo"The file $filename exists";
  6. }else{
  7. echo"The file $filename does not exist";
  8. }
  9. ?>

Viewing all articles
Browse latest Browse all 178

Latest Images

Trending Articles



Latest Images