LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 846|回复: 1

为什么无法在浏览器中加载CGI程序?

[复制链接]
发表于 2005-11-22 23:10:25 | 显示全部楼层 |阅读模式
我的OS是Fedora Core 4,浏览器是Firefox,在保证perl语言编译器与apache(httpd)服务完全正常的前提下,我在/var/www/html下编辑file_upload.html文件:

<HTML>
<HEAD></HEAD>
<BODY>
<FORM ACTION="/cgi-bin/file_upload.cgi" METHOD="post" ENCTYPE="multipart/form-data">
Photo to Upload: <INPUT TYPE="file" NAME="photo">
<br><br>
Your Email Address: <INPUT TYPE="text" NAME="email_address">
<br><br>
<INPUT TYPE="submit" NAME="Submit" VALUE="Submit Form">
</FORM>
</BODY>
</HTML>


同时在/var/www/cgi-bin下编辑file_upload.cgi文件(文件权限755):

#!/usr/bin/perl -w

use CGI;

$upload_dir = "/upload";

$query = new CGI;

$filename = $query->param("photo");
$email_address = $query->param("email_address");
$filename =~ s/.*[\/\\](.*)/$1/;
$upload_filehandle = $query->upload("photo");

open UPLOADFILE, ">$upload_dir/$filename";

binmode UPLOADFILE;

while ( <$upload_filehandle> )
{
   print UPLOADFILE;
}

close UPLOADFILE;

print $query->header ( );
print <<END_HTML;

<HTML>
<HEAD>
<TITLE>Thanks!</TITLE>
</HEAD>

<BODY>

<>Thanks for uploading your photo!</P>
<>Your email address: $email_address</P>
<>Your photo:</P>
<img src="/upload/$filename" border="0">

</BODY>
</HTML>

END_HTML


它们实现的功能很简单:用户上传一个图片,然后在浏览器中显示。

在浏览器中做测试时,html可以正常显示表单,但在点击Submit按钮之后,浏览器显示500错误:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, root@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.
Apache/2.0.54 (Fedora) Server at 192.168.0.102 Port 80


我又察看了日志下的access.log文件,里面描述这段操作的是这么几句:

192.168.0.102 - - [22/Nov/2005:22:20:23 +0800] "GET /file_upload.html HTTP/1.1" 304 - "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.0.7-1.1.fc4 Firefox/1.0.7"

192.168.0.102 - - [22/Nov/2005:22:20:23 +0800] "GET /favicon.ico HTTP/1.1" 403 411 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.0.7-1.1.fc4 Firefox/1.0.7"



192.168.0.102 - - [22/Nov/2005:22:20:55 +0800] "OST /cgi-bin/file_upload.cgi HTTP/1.1" 500 613 "http://192.168.0.102/file_upload.html" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.0.7-1.1.fc4 Firefox/1.0.7"

192.168.0.102 - - [22/Nov/2005:22:20:55 +0800] "GET /favicon.ico HTTP/1.1" 403 411 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.0.7-1.1.fc4 Firefox/1.0.7"


请问该如何解决此问题呢?
发表于 2005-11-26 11:49:48 | 显示全部楼层
兄弟的 /upload 是否777 了? 還有 <img src="/upload/$filename" border="0"> 看?砣思乙床坏搅
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表