How to download a .php file from its location using the browser address bar?

5 replies
when you type the end of the Extension to the file (.exe .zip .doc etc) it will automatically ask to be downloaded and you could save or open.

But this does not seem to work with a php file, I want to download from a server, which I found the location for. It just opens the page as blank. And no source code is in it. right click ,save target as..also doesn't work here.

So is there a way of downloading a php from directly from the browser?
any software or by any means?
#address #bar #browser #download #file #location #php
  • Profile picture of the author tosbourn
    Short answer: you can't.

    Explanation:

    How these files are handled by your browser is up to the server that is hosting the files, by default the files you mentioned are told to be downloaded by the server (.exe, .zip etc).

    The default configuration for handling PHP files is to execute the file and serve up the contents, so what you are seeing is the output of the PHP file, not the PHP file.
    {{ DiscussionBoard.errors[7994637].message }}
  • Profile picture of the author Brandon Tanner
    If the PHP file is located on a remote server, then the answer is NO! (thankfully ). Browsers can not access server-side code directly (PHP, CGI, etc.)... they can only display what the server outputs to the browser (HTML, CSS, Javascript, etc).

    If the PHP file is on your own server, on the other hand, and you want to give people the ability to download it, then you can just put it in a zip file.
    Signature

    {{ DiscussionBoard.errors[7994643].message }}
  • Profile picture of the author Altin
    It is not possible so don't waste your time trying to do it. PHP is a server side scripting language so you only see it's result after it has been processed from the online server. If it was that we could download PHP files then I would download wp-config file in all wordpress blogs and see their database name, username and password and easily hack any site I wanted thankfully PHP files cannot be downloaded, neither show their source from a browser.
    {{ DiscussionBoard.errors[7995807].message }}
  • Profile picture of the author Rob Whisonant
    The others have given you your answer but I'm going to explain it in non programmer language for any that are interested.

    Consider the server as a black box. Consider PHP as the steps to solve something. Consider the browser as the answer board.

    For example. PHP code that contains the math formula 5 + 2 = is calculated at the server and the solution is sent to the browser. The solution in this case is 7. The browser only receives 7 as the server executes and solves the formula before the results (answer) is sent out from the server to the browser. The math formula 5 + 2 = is never sent out from the server to the browser unless the server is not configured correctly to execute PHP.

    Re's
    Rob Whisonant
    {{ DiscussionBoard.errors[7996335].message }}
  • Profile picture of the author Amod Oke
    Out of curiosity, why would you want to download someone else's php file??
    {{ DiscussionBoard.errors[7996594].message }}

Trending Topics