App only downloading php files
If such kind of file is stored in a public accessible folder, you can just create a hyperlink pointing to that file, and whenever a user click on the link, browser will automatically downloads that file. Clicking a link that points to a PDF or an Image file will not cause it to download to your hard drive directly.
It will only open the file in your browser. Further you can save it to your hard drive. Active Oldest Votes. You might have only have the cli version of PHP installed currently try sudo apt-get install php5 and restart apache sudo apache2ctl restart. You can also check the PHP module is loaded into apache by doing sudo apache2ctl -M Which if the module is loaded then it should show something like Loaded Modules Syntax OK.
Improve this answer. Mark Davidson Mark Davidson 4 4 silver badges 11 11 bronze badges. Add a comment. Thanks a lot. It would look something like this: Use for PHP 5. Do NOT set it to On as it prevents. I did what it says and restarted apache and the problem had gone. Adrian Heine 4 4 silver badges 22 22 bronze badges. Connect and share knowledge within a single location that is structured and easy to search.
I previously had php 5. I first uninstalled the php 5. I have checked similar questions here in stackoverflow but none of them have helped me so far. For the record I have the following lines in my httpd. Now apache is showing the source code, but not all of it just part. I added. When you're configuring apache then try to view the page from another browser - I've had days when chrome stubbornly caches the result and it keeps downloading the source code while in another browser it's just fine.
I came across this issue today and none of the solutions described worked for me. So here is another possible cause:. In my case the server did not know the x-mapp-php6 type, since that. Just removing the AddHandler line from the.
If you are prompted to download a. Turns out files shouldn't be stored in mods-enabled , but should rather be stored in mods-available. A symlink should then be created in mods-enabled pointing to the file stored in mods-available. Regarding the suggestion above that you should tell the browser that you are outputting a PHP script: It seemed like an unusual idea to me.
I googled it and found that there is quite a bit of discussion about it on the web. If Your. This might be happening due to the missing modules required for your php. Assuming you have php7 installed, search available php7 modules using. Above command will list all available PHP7 modules for installation. You can begin installation of modules like,. I have the same problem. Apache doesn't load php files from a certain website, just downloaded it. I read this post and the answers and I have seen I've got this line into the last place of the.
After updating PHP to 7. I previously has a similar issue, after upgrading from 5. I spent two days tracking this and found out that I was putting my PHP scripts in the wrong directory. I just started PHP work, so I don't know if my solution relates to the version change you went through. I had this problem. It turned out that I had both nginx and apache installed and automatically starting on boot.
The problem was that nginx was binding to the http port first which prevented apache from starting. Share on twitter. Share on linkedin. Share on reddit. Use headers correctly This is a very widespread problem and unfortunately even the PHP manual is plagued with errors. Forcing download and Internet Explorer bugs What would it be like to not having to worry about old versions of Internet Explorer?
Handling large file sizes readfile is a simple way to ouput files files. Closing thoughts I did my best to provide only accurate information. Next Photography on the iPad Next. Armand Niculescu. As the Senior Project manager, Armand is one of the rare kind of developers that can do both design and programming with equal skill. This, coupled with a solid background and many years of experience, enables him to see the big picture and plan for the small details.
The first argument is mandatory, and the other two arguments are optional. This function returns the number of bytes read from the file mentioned in the first argument. The uses of this function are shown in the following two examples.
In this example, we will create an HTML file with the following code, where the file name will be passed as a parameter of the URL named path , and the value of this parameter will be passed to the PHP file named download.
We will create the PHP file with the following code to download the file forcibly. Next, the header function is used to set the necessary header information before using the readfile function. The basename function is used to retrieve the filename, and the filesize function is used to read the size of the file in bytes, which will be shown in the opening dialog box to download the file.
The flush function is used to clear the output buffer.
0コメント