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.
- <?php
- $filename='/tmp/audio.mp3';
- if(file_exists($filename)){
- echo"The file $filename exists";
- }else{
- echo"The file $filename does not exist";
- }
- ?>