CGI或HTML文件上的图像 [英] images on CGI or HTML files

查看:252
本文介绍了CGI或HTML文件上的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我为自己运行小型本地主机,但是当我编写CGI文件或HTML文件时,它会显示除图像之外的所有内容。大家都知道发生了什么,我该怎么办?

Recently, I run small local host for myself, but when I write a CGI file or HTML file, it shows everything except images. Does everyone know what happen and what shall I do?

推荐答案

因为你没有给我们任何足够的信息,所以无法回答。但是你的代码确实给出了一个潜在的线索。

Impossible to answer because you haven't given us anywhere near enough information. But your code does give one potential clue.

use CGI qw/:standard/;
use DBI;

print "Content-type:text/html\n\n";
print first();
print myform();
print second();

sub myform {
  return <<B;
<form action='' method='post'>
  <img src="images/img0001.gif" id="Shape1" align="top" alt="" title="" border="0" 
       width="1344" height="126">
  ...
</form>
B
}

您尝试从<$ c $提供图像C>图像/ img0001.gif 。但这与当前目录相关 - 当执行此代码时,几乎肯定会是 / cgi-bin 。并且大多数Web服务器都配置为假定 / cgi-bin 下的任何文件都是CGI程序。

You try to serve the image from images/img0001.gif. But that's relative to the current directory - which will almost certainly be /cgi-bin when this code is executed. And most web servers are configured so that any files under /cgi-bin are assumed to be CGI programs.

所以我猜你的网络服务器正试图执行你的图像文件。哪个不行。 Web服务器错误日志中有什么?

So I'd guess that your web server is trying to execute your image file. Which isn't going to work. What's in the web server error log?

将任何静态文件(html,images,css)移出 / cgi-bin 目录。

Move any static files (html, images, css) out of the /cgi-bin directory.

这篇关于CGI或HTML文件上的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆