Jump to content


Photo

Newbie: fopen-question


  • Please log in to reply
1 reply to this topic

#1 TheNewbie

TheNewbie
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 23 September 2006 - 11:11 AM

I guess this is a newbie-question, but I couldn't find any section just for newbies, so please excuse me if this post is out of place and direct me in the right direction.  :-[

This works fine when it runs from the same directory as 'text.txt':
$filename="text.txt";
$fd = fopen($filename, "r") or die("Cannot open file $filename");
$fstring = fread( $fd, filesize($filename));fclose($fd);

But I want it to work from other directories as well, but this doesn't work as $fstring seems to turn up empty:
$filename="http://www.mydomain/text.txt";
$fd = fopen($filename, "r") or die("Cannot open file $filename");
$fstring = fread( $fd, filesize($filename));fclose($fd);

How can I make it work?




#2 TheNewbie

TheNewbie
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 23 September 2006 - 01:59 PM

I think I made it work. PHP is running in safe-mode which means that url-fopen is not allowed. Instead of refering to the file with http I refered with respect to the server-root. This seems to have solved the problem as I now can open it from any directory.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users