Jump to content

files_exists() question


ballhogjoni

Recommended Posts

use php.net for refrences ok mate..........

 

 

file_exist needs the server path..........

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

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

 

 

useing headers can see if the file exist via a full external url...

 

<?php
$file = 'http://www.domain.com/somefile.jpg';
$file_headers = @get_headers($file);
if($file_headers[0] == 'HTTP/1.1 404 Not Found') {
   $exists = false;
}
else {
   $exists = true;
}
?>

I am not familiar with the term "filesystem path", is that another term for absolute path?

 

Yeah sorry, my bad. You could probably lose the filesystem part.

 

use php.net for refrences ok mate..........

 

maybe you ought take your own medicine. file_exists() works perfectly well given a url providing the correct wrappers are installed and enabled.

thx,

 

all that being said I have the following code that does not work. I am on shared hosting so I don't know which wrappers are on and which ones are off (is there a way to tell?).

 

$flag_image = ABSOLUTE_PATH."public_html/xxxxxx/articles/images/flags/". $myrow['flag']. ".gif";
		echo $flag_image;
		if (file_exists($flag_image)) {
			$size = getimagesize($flag_image);
			echo " <img src='" . FACS_href . "articles/images/flags/" . $myrow['flag']. ".gif' " . $size[3] . " alt=''/>";
		}

 

the script will echo the $flag_image but the script dies after that, I assume this means that file_exists is not working correctly. Any advice?

how do u set it to not be absolte then.........

 

file_exists(http://www.example.com)  << what do u enable to get the correct result......

 

all ive read is use file_get_contents() <<<<< use that as what i can read ........

 

please advise me then sorry everyone..............

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.