PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
$filename = "http://www.domain_name.com/files/category1.txt";
if (file_exists($filename)) {
echo "yes exists.<br>";
}else{
echo "no does not exist.<br>";
}
if (is_readable($filename)) {
echo "yes readable.<br>";
}else{
echo "no not readable.<br>";
}
if (is_executable($filename)) {
echo "yes executable.<br>";
}else{
echo "no not executable.<br>";
}
$file = fopen($filename, "r");
$text = fread($file, 112);
fclose($file);
echo("File Size: $filesize bytes");
echo ( "<pre>$text</pre>");
I get this output....
no does not exist.
no not readable.
no not executable.
File Size: bytes
1,this is a test link,site name,description stuff here
2,this is a test link2,site name2,description stuff here2
So the script denies the file is there and YET echo's the file anyhows?????
is_readable(), is_writable(), is_executable(), filesize(), among several other functions require access to the file system. Files on another server are not in the local machine's file system. They are called stat() based functions, this is why they fail..
strlen() of file_get_contents(). If you run PHP 5, you could use get_headers() first to determine if the content-length header is sent, but you'd still have to get the file itself if it wasn't..