index.php 未在下载文件时打开和运行 [英] index.php is not opening and running as download the file
问题描述
当我尝试导航到位于 http://localhost/project/admin 的 PHP 脚本时,我希望在我的网络浏览器中查看脚本结果.
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:
您已选择打开
,这是一个:application/x-httpd-php
来自:http://localhost
Firefox 应该如何处理这个文件?打开方式...
•保存...
•等
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...
•Save...
• etc.
知道发生了什么吗?
推荐答案
听起来像是发送了不正确的 Content-type
标头.此标头为浏览器接收的数据设置 mime 类型,如果浏览器没有处理程序来呈现该特定 mime 类型,它将要求打开/保存文件.
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.
我会首先检查您的 PHP 文件中是否存在 header()
语句和错误类型的内容类型.
I would start by checking your PHP file for a header()
statement and a mis-typed content-type.
这篇关于index.php 未在下载文件时打开和运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!