Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
461 views
in Technique[技术] by (71.8m points)

perl - images on CGI or HTML files

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

";
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
}

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.

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?

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...