PHP文件自动下载,而不是在浏览器中显示? [英] php file automatically downloads instead of displaying in browser?
问题描述
在我的html文件中,我尝试链接到一个php文件(表单动作):
<!DOCTYPE html>
< html>
< head>
< title> Google< / title>
< / head>
< body>
< div style =text-align:center>
< h1> Google< / h1>
< form action =server.phpmethod =get>
< input name =qstyle =width:300pxtype =text>
< br>
< input type =submitvalue =Google Search>
< input type =submitvalue =我很幸运>
< / form>
< / div>
< / body>
< / html>
server.php
只是一点点
当我点击链接google search时,chrome下载文件而不是获取 server.php
我chmod google.html到rw - r - r
我chmod server.php到rw --------或600
如何让它停止下载 server.php
?
您需要在服务器上运行PHP。如果你没有网络服务器,它只会下载文件,因为没有任何东西可以解析脚本。
查看WAMP(适用于Windows), LAMP(用于linux)或MAMP(用于mac)
In my html file I try to link to a php file (form action):
<!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
is just a little bit of html code.
When I click on the link "google search" chrome downloads the file instead of getting server.php
I chmod google.html to rw - r - r
I chmod server.php to rw -------- or 600
How do I get it to stop downloading server.php
?
You need to be running PHP on your server. If you don't have a web server, it will just download the file as there is nothing to parse the script.
Have a look at WAMP (for windows), LAMP (for linux) or MAMP (for mac)
这篇关于PHP文件自动下载,而不是在浏览器中显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!