Link to home
Start Free TrialLog in
Avatar of hankknight
hankknightFlag for Canada

asked on

fopen opening remote files but not local ones

Hello.

I am trying to use fopen to open a local file.

    $fp = fopen("/home/mysite/public_html/pages/test.php", 'r');

does not work

    $fp = fopen("/home/mysite/public_html/pages/test.php", 'r');

does not work either


But, if I put it as a web address it works:
    $fp = fopen("http://www.mysite.com/pages/test.php", 'r');
      

How can I get this to open my local file without having to use http?

Here is my code.

Thanks!

    <?php
    $fp = fopen("http://www.mysite.com/pages/test.php", 'r');
    if (stream_set_timeout($fp, 15) == false){
                echo "Error: Could Not Connect";
        fclose($fp);
    }
    elseif (!$fp){
                echo "Error: Could Not Connect";
        fclose($fp);
    }
    else{
     @fgets($fp);
    fclose($fp);
    }
    ?>
SOLUTION
Avatar of Diablo84
Diablo84

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of Marcus Bointon
Marcus Bointon
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hankknight

ASKER

Aggggg!  Those aliases!  The log helped me to identify the propor path.