Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

index.php is not opening and running as download the file

Tags:

php

apache

When I attempt to navigate to the PHP script at http://localhost/project/admin, I expect to see the script results in my web browser.

Instead, I see a dialog box for downloading the file with the message below:

You have chosen to open <filename>, which is a: application/x-httpd-php from: http://localhost
What should Firefox do with this file? Open with... &bullet; Save... &bullet; etc.

Any idea what is going on?

like image 637
designer-trying-coding Avatar asked Mar 15 '10 12:03

designer-trying-coding


2 Answers

PHP is not correctly installed on the server or Apache is not using mod_php

In the case of this happening in IIS. I would say that the mimetype is not setup correctly and that the server doesn't know how to handle the extension ".php"

like image 152
Pieter Germishuys Avatar answered Nov 15 '22 10:11

Pieter Germishuys


It sounds like an incorrect Content-type header is being sent. This header sets the mime-type for the data the browser receives and, if the browser doesn't have a handler to render that specific mime-type, it will ask to open/save the file instead.

I would start by checking your PHP file for a header() statement and a mis-typed content-type.

like image 33
Andy E Avatar answered Nov 15 '22 11:11

Andy E