images on CGI or HTML files

不羁的心 提交于 2019-12-14 00:10:04

问题


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?


回答1:


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
}

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.




回答2:


Finally my problem solved. As my cgi-bin folder was in home/username/public_html, I put my images folder in home directory. But when I saved my images in var/www/ , everything was corrected.



来源:https://stackoverflow.com/questions/26614013/images-on-cgi-or-html-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!