Open file under IIS Web Server

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!

Moderator: General Moderators

Post Reply
Pancoro
Forum Newbie
Posts: 4
Joined: Fri Oct 06, 2006 6:06 am

Open file under IIS Web Server

Post 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:
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post 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.
Post Reply