Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Are logo.html and logotest.cfm in the same directory?
Copy link to clipboard
Copied
Yes. Same directory.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.