How can I download a php file from a website ?
-
Whenever I try downloading the file the downloaded just downloads an HTML file. I want to download a php file stored on someones site, I don't have any ftp access to their site but I have the exact address where the file is stored on the server. Whenever I try downloading the .php file on that site my download manager aways downloads a redirected html file, is there any way to download the source php file.
-
Answer:
PHP is code that runs in the environment termed "server-side". This means that when your browser makes a request to read a PHP file, the web server does not serve up the file to you - instead, it executes the file using one of several possible PHP runtimes, and then returns to your browser the output of that PHP program. For this to all work properly, the web server must be configured to perform this execution. A malconfigured server might not do this properly, and might return the actual script to your browser. In nearly all cases, this is not just undesirable, it is a bit of a security problem as well. PHP programs tend to have proprietary information, such as hard coded passwords and SQL statements that reveal database structure. Contrast this with JavaScript, which is usually used in a client-side execution model, in which the actual script with all its code is pulled down by your browser and executed by the browser's JavaScript engine. Two very different ways of getting things done. At one time, server-side execution was king, but now we are moving more functionality to the client, and relegating the server to being a simple business logic engine. Result is snappier rendering and a lot of apps that couldn't be built to be responsive enough with server-side technology.
Mark Nelson at Quora Visit the source
Other answers
There may be several problems here. The first most likely problem comes from the way php files are interpreted on a server - I'm not entirely sure of the tech terms but I think if you try to access the file through a web browser (via http - ?) the file is interpreted and you get passed the results of the file. This is correct behaviour otherwise php wouldn't work The way we need. The second problem would be if the file is being served as a download so you are not accessing it via http then you may have incorrect file permissions on the file (most likely if it is a Linux server) or there is something wrong in the page serving the download. There my be other problems but those would be my first guesses.
Callum Rexter
The moment you hit http:// some-domain .com/ page.php to download it ,the server is going to execute that script.( Php gets interpreted). To download it here is something you must do : 1) use FTP:// 2) use cPanel
Abhishek Rana
The way I understand either you want the code that is running at a URL or you want the visitor at your website to be able to download a PHP file which they can use. If you want to download source code of a url running a PHP file You can't, reason PHP is a server side language that means your browser or client side never receives PHP code. All you get is the interpreted result from PHP code that was executed on remote server. If you want a user to be able to download a PHP file Send right headers for force download by a script and pass the PHP script written in single quotes to output stream. Example: <?php$code = '<?php echo "hello world" ?>'; ?> David Walsh wrote great here about headers https://davidwalsh.name/php-force-download But I would suggest using gist and/or public repository for sharing code with your users.I hope I could answer your queryHappy downloading!
Sarthak Sawhney
Related Q & A:
- How can I send a .mht file as blat attachment?Best solution by Stack Overflow
- In Visual Studio 2012 or 2013, how can I register a DLL file on Windows 7 64-bit computer using a Custom Action command?Best solution by Stack Overflow
- How can I burn a .rmvb file onto a DVD for viewing on a regular DVD player?Best solution by Yahoo! Answers
- How can I open a vcf file?Best solution by file.org
- How can I open a jpeg file?Best solution by answers.microsoft.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.