Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

IMG SRC not finding file from CFM

Guest
Jul 13, 2011 Jul 13, 2011

Hi, I'm using ColdFusion9 with the 9.01 update and ColdFusion Builder 2 on port 80 on IIS 7.5.7600.16385.  When I run the following line in logo.html the gif is properly displayed:

<img src="../images/logo_c.gif" alt="Orange Whip Studios"/>

When I run the line in logotest.cfm the alt text is displayed, even though FileExists finds the gif at that path.  Any idea why?  Thanks.

1.9K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 13, 2011 Jul 13, 2011

Are logo.html and logotest.cfm in the same directory?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 13, 2011 Jul 13, 2011

Yes.  Same directory.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 13, 2011 Jul 13, 2011

The URL in an IMG tag is not relative to the file the tag is in, it's relative to the path in the URL of the mian request (ie: in the address bar of the browser).  I suspect "../images/logo_c.gif" is not valid, relative to the address in the address bar..?

--

Adam

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 14, 2011 Jul 14, 2011

The path for the img src is the same in both the html file and in the cfm file and both files are in the same directory.  The html file finds and correctly displays the image.  The cfm file finds it, as determined by FileExists, but it does not properly display it.  Same path, same gif file, same directories.  It's weird.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jul 14, 2011 Jul 14, 2011

What does the HTML output show when you call the .cfm page? It cannot be the same as the static HTML page, else it'd show in both.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 14, 2011 Jul 14, 2011

Yeah, but is the URL in the browser the same for both HTML and CFM requests?  Nothing you said addresses that.  The fact the CFM file is in the same dir as the HTM file does not imply that the URLs are the same.  For example if you're using Fusebox or similar, then your URL could well say /index.cfm?fuseaction=foo.bar, which in turn includes /some/other/path/file.cfm.  And if your image is in  /some/other/path/, the browser ain't gonna find it if you have an image source of "../images/logo_c.gif".

It doesn't matter where the image is in relation to the CFM file, it matters where it is in relation to the browser's URL.

But if that's all legit, work out the URL you need to use to fetch the image (so something you can put int he browser address bar and the image comes back), and compare that with the URL your mark-up is using, and adjust accordingly.

--

Adam

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 14, 2011 Jul 14, 2011
LATEST

Okay, I have it working.  My cfm files are in C:\ColdFusion9\wwwroot\ows\14.  My image files were in C:\ColdFusion9\wwwroot\ows\images.  When I run cfm file insert1.cfm from ColdFusion Builder 2 the URL in the browser is localhost/ows/14/insert1.cfm.  When I set IMG SRC="../images/logo_c.gif" the image was not being properly displayed.  However, after moving the image files to C:\inetpub\wwwroot\owsimages and setting IMG SRC="/owsimages/logo_c.gif" the images are now being properly displayed.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources