All possible ways to read a file from a remote server

i want to provide most possible flexibility for my script and so i need all possible ways in php and javascript to read the content(not sourcecode) of a php file from a remote server.
so far i found curl, fopen and include for php and none for javascript, but i dont even know if this is possible with javascript.
Thanks for any hint.

  • How to create a tmp dir in node without collisions
  • Access local file modification time in javascript
  • Create image from ArrayBuffer in Nodejs
  • External or Inline JavaScript? - Page Load Time
  • Download page as pdf file
  • How do I Validate the File Type of a File Upload?
  • Can you save/load a file via Javascript?
  • Find all images in folder with Javascript
  • How can I iterate through files in Javascript
  • HTML5 Preview large images quickly
  • What is JavaScript FileReader and where it could be used?
  • Writing a javascript file from another javascript
  • 3 Solutions collect form web for “All possible ways to read a file from a remote server”


      - fopen() + fread()
      - file_get_contents()
      - curl
      - executing shell commands
            `wget '' -O saved.htm`;
            $result = `cat saved.htm`;


      // not for remote server
      var req = new XMLHttpRequest();'GET', '', false);
      if (req.readyState==4) alert(req.responseText);

    You’ve got the major options for PHP figured out.

    As for javascript (assuming it’s running in a web browser), the same-origin policy will complicate things.

    Possible workaround for Javascript include:

    • Using a script-tag proxy

    • Using a PHP proxy script on the domain that your page is loaded from. Your javascript asks the PHP script to grab the remote content. PHP script does that, and outputs the contents back to you javascript.

    Javascript is a client side scripting language primarily, you can’t just simply get an external resource with it without either

    • server-side help ( xhr to
      server-side page to do curl/wget )
    • the resource has to be on your
      domain and you can XMLHttpRequest it without server-side help.