Jump to content


Photo

[resolved] Check if a file exists...


  • Please log in to reply
3 replies to this topic

#1 ibanez270dx

ibanez270dx
  • Members
  • PipPipPip
  • Advanced Member
  • 53 posts

Posted 10 August 2006 - 11:30 PM

Hi,
How do I check if a file exists on my server? I am currently using an if($filename2) where the $filename2 is thename.xls (the files are located in the same directory). This doesn't seem to work... it just automatically goes to the statement afterward even if the file doesn't exist. Someone please help!

Thanks,
- Jeff

#2 Jocka

Jocka
  • Members
  • PipPipPip
  • Advanced Member
  • 344 posts
  • LocationDallas, Texas

Posted 10 August 2006 - 11:33 PM

if(file_exists($filename2))

::EDIT::
http://us3.php.net/file_exists

#3 spfoonnewb

spfoonnewb
  • Members
  • PipPipPip
  • Advanced Member
  • 276 posts

Posted 10 August 2006 - 11:34 PM

Php manual example:

<?php
$filename = '/path/to/foo.txt';

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


#4 ibanez270dx

ibanez270dx
  • Members
  • PipPipPip
  • Advanced Member
  • 53 posts

Posted 10 August 2006 - 11:42 PM

wow... that was pretty obvious...  :-[  thanks for your help!!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users