How to to check file exists or not using php

Sponsors

Many times we got requirement of check file from specific directory. Following code will work in all the system like (Mac, Linux and Windows).

Using following php code you can check file is present or not in specific directory.


<?php
 $filename = '/var/www/html/test/test.txt';

 if (file_exists($filename)) {
 echo "The file $filename exists";
 } else {
 echo "The file $filename does not exist";
 }

?>

Incoming search terms:

You may like following Articles!

This entry was posted in PHP, tutorials and tagged , by Wordpress API. Bookmark the permalink.

About Wordpress API

API means Application Program interface. In Wordpress API we are giving all the information about wordpress API. We worked for many wordpress plugins and themes. We have expertise in PHP, Databases, Graphic Design, Ruby on Rails, Java, Wordpress, Drupal and many CMS. We always give you the best solutions about wordpress and other related topics in This Blog. We will give you always fresh tips and tricks and techniques about wordpress in this blog.

4 thoughts on “How to to check file exists or not using php

  1. Pingback: Tweets that mention How to to check file exists or not using php | Wordpressapi.com - Developer Code book -- Topsy.com

  2. Functions of Mozilla Firefox: Mozilla Firefox is an open source web browser, helping million of users to surf through net with ease. It has number of added features like add-ons, which are developed by third party, tabbed browsing, download manager and so on.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>