Opening a file or a url in the same script

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kelly

    Opening a file or a url in the same script

    I wrote this script to work on local files is there a way I can change
    something here so
    that I can add a url and run that through the script aswell?


    ---------------------------------------------------------------------
    <form action="<?= $PHP_SELF ?>" method="POST">
    URL: <input type="text" name="url" value="<?= $url ?>"/><br>
    <input type="submit">
    </form>

    // this is after the form is posted
    $remote = fopen($url, 'r');
    $html = fread($remote, 1048576);
    fclose($remote) ;
    ---------------------------------------------------------------------

    The script is working I just want to add this functionality but I don't even
    know how to go about looking something like this up. It seems to work
    once in awhile but not consistently and I think it is the way it is opening
    the webpage. If I copy the same page and run it on my machine as a local
    file it always works.


    Thanks,
    Kelly



Working...