Page 1 of 1

Open file under IIS Web Server

Posted: Fri Oct 06, 2006 6:46 am
by Pancoro
Our computer using IIS Web Server.
I have strange problem to open a XML file that placed in another computer. My script just open XML file in local (my own PC), this is the script:

<?php
function LoadTpl($template="") {
$filename = $template;
if ( file_exists($filename) ) {
if ( $FH = fopen($filename, "r") ) {
$template = fread( $FH, filesize($filename) );
fclose($FH);
} else {
die("The file can't opened.");
}
} else {
die("File: ".$filename." isn't found.");
}
return $template;
}

$temp=LoadTpl("[Path of file in my own PC]");
echo $temp;

?>

It works.
But, when I replace the path with http:\\[IP number (target)]\[location of file]\[filename][extension],
Message "File: ".$filename." isn't found." appeared.

When I use my browser (IE) the file is showed, but when I use the script, it isn't work. :?

Thanks for your help ! :wink:

Posted: Fri Oct 06, 2006 6:55 am
by aaronhall
file_exists() has to interact with the file system, so it won't work on a remote URL. Try checking if the URL is returning a "HTTP/1.1 200 OK" header with get_headers.