【问题标题】:php file automatically downloads instead of displaying in browser?php 文件自动下载而不是在浏览器中显示?
【发布时间】:2014-01-03 17:34:01
【问题描述】:

在我的 html 文件中,我尝试链接到一个 php 文件(表单操作):

<!DOCTYPE html>
  <html>
    <head>
      <title>Google</title>
    </head>
    <body>
      <div style="text-align: center">
        <h1>Google</h1>
          <form action="server.php" method="get">
          <input name="q" style="width: 300px" type="text">
            <br>
          <input type="submit" value="Google Search">
          <input type="submit" value="I'm Feeling Lucky">
          </form>
        </div>
      </body>
    </html>  

server.php 只是一点点html代码。

当我点击链接“google search”时,chrome 会下载文件而不是获取server.php

我 chmod google.html 到 rw - r - r

我 chmod server.php 到 rw -------- 或 600

如何让它停止下载server.php

【问题讨论】:

  • 只不过是带有.php扩展名的html
  • 格式为.php doc的文件吗?
  • 文件名是server.php,里面的内容只有html: Google

    即将推出

  • 但是格式为 .php 文档的文件吗?
  • 不,不是 php 文档,只是一个扩展

标签: php html


【解决方案1】:

您需要在您的服务器上运行 PHP。如果你没有网络服务器,它只会下载文件,因为没有什么可以解析脚本。

看看 WAMP(适用于 windows)、LAMP(适用于 linux)或 MAMP(适用于 mac)

【讨论】:

  • 也可能是 xampp/easyphp?
  • 我在运行 linux 的 VM 上安装了 LAMP,PHP 版本 5.5.3
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-01-18
  • 2014-07-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多