为什么 cgi 页面中包含的图像没有显示在浏览器中?

发布于 2024-09-29 02:37:26 字数 1210 浏览 0 评论 0原文

我希望每个人都过得很好。 我面临着有关图像的问题,我有一个 cgi 页面,即 Login.cgi,在 html 部分中我包含了一些图像,但有些图像正在显示,有些则没有。

代码如下:

       #!C:\perl\bin\perl.exe
      use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
      use strict;
      print "Content-type: text/html\n\n";

      print <<END2;
      <html>
      <head><title>LOGIN</title></head>
      <body>
         <table>
           <tr>  
            <td background="C:/Program Files/Apache Software Foundation/Apache2.2/cgi-
               bin/template_3/images/login2222.PNG" style="height: 135px; width:
                 100px;">
              <img src="C:/Program Files/Apache Software Foundation/Apache2.2/cgi-
                   bin/template_3/images/ineer-top-left.gif"/>
             </td>
           </tr>
       </table>
      </body>
     </html>
     END2

在这两个图像中,td 标签的“背景图像”正确显示,但 td 内的图像没有正确显示。

实际上, 我尝试将内容类型更改为“image/gif”,但它不起作用。 我尝试将 src 更改为“../template_3/images/ineer-top-left.gif”或类似的内容 “~/template_3/images/ineer-top-left.gif”,但它不起作用。

当我右键单击浏览器中的图像并检查属性时“它给出了类型:不可用 尺寸:无货 但地址(URL)是正确的。 有人可以帮我找到解决方案吗?谢谢

I hope everyone's doin good.
I am facing an issue regarding the images, i have a cgi page i.e Login.cgi, in tha html section i have included some images but some are getting displayed and some are not.

Here's the code:

       #!C:\perl\bin\perl.exe
      use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
      use strict;
      print "Content-type: text/html\n\n";

      print <<END2;
      <html>
      <head><title>LOGIN</title></head>
      <body>
         <table>
           <tr>  
            <td background="C:/Program Files/Apache Software Foundation/Apache2.2/cgi-
               bin/template_3/images/login2222.PNG" style="height: 135px; width:
                 100px;">
              <img src="C:/Program Files/Apache Software Foundation/Apache2.2/cgi-
                   bin/template_3/images/ineer-top-left.gif"/>
             </td>
           </tr>
       </table>
      </body>
     </html>
     END2

Among these two images, the td tag's 'background image' is getting displayed properly, BUT not the image within td.

Actually,
i tried changing the content-type to "image/gif", but it did not work.
i tried changing the src to "../template_3/images/ineer-top-left.gif" or something like
"~/template_3/images/ineer-top-left.gif",but it did not work.

When i right clicked the image in the browser and checked the Properties "it gives the TYPE: not available
SIZE : not available
BUT the ADDRESS(URL) is Correct.
Can anybody Please Help me find the solution.Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

一袭水袖舞倾城 2024-10-06 02:37:26

既然你调用这个 CGI,你必须运行一个 Web 服务器(apache?),所以我猜你正在本地主机上访问它。在这种情况下,请考虑使用“/cgi-bin/template_3/images/ineer-top-left.gif”等相对路径或“http://127.0.0.1/cgi-bin/template_3/images/”等绝对路径ineer-top-left.gif”而不是文件系统上的位置。您可能需要尝试一下存储图像的位置以及站点的根目录所在的位置。

Since you're calling this CGI, you must be running a web server (apache?), so I'm guessing you're accessing it at localhost. In that case, consider using a relative path like "/cgi-bin/template_3/images/ineer-top-left.gif" or an absolute path like "http://127.0.0.1/cgi-bin/template_3/images/ineer-top-left.gif" rather than a location on your filesystem. You may have to play around with where you store the images and where the root directory of your site is.

你怎么敢 2024-10-06 02:37:26

首先,您为图像提供的 URL 必须是真实的 URL,而不是文件路径。

其次,您的 Web 服务器可能被配置为认为 cgi-bin 目录中的所有内容都是 CGI 程序。这意味着,如果您给它一个指向该目录的 URL,Web 服务器将尝试执行该程序,而不是直接提供内容。您需要将静态内容(如图像)移出 cgi-bin 目录。

Firstly, the URLs you give for your images need to be real URLs and not file paths.

And secondly, your web server is probably configured to think that everything in the cgi-bin directory is a CGI program. That means that if you give it a URL which points to that directory, the web server will try to execute the program rather than directly serving the content. You'll want to move static content (like images) out of the cgi-bin directory.

命硬 2024-10-06 02:37:26

希望这可能有效

  #!C:\perl\bin\perl.exe
  use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
  use strict;
  print "Content-type: text/html\n\n";

  print '
  <html>
  <head><title>LOGIN</title></head>
  <body>
     <table>
       <tr>  
        <td background="../login2222.PNG" style="height: 135px; width:
             100px;">
          <img src="../ineer-top-left.gif"/>
         </td>
       </tr>
   </table>
  </body>
 </html>
 ';

Hope this might work

  #!C:\perl\bin\perl.exe
  use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
  use strict;
  print "Content-type: text/html\n\n";

  print '
  <html>
  <head><title>LOGIN</title></head>
  <body>
     <table>
       <tr>  
        <td background="../login2222.PNG" style="height: 135px; width:
             100px;">
          <img src="../ineer-top-left.gif"/>
         </td>
       </tr>
   </table>
  </body>
 </html>
 ';
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文