Skip to main content
Inspiring
June 15, 2009
Question

Space in Img File Name - Renders in FireFox but Not IE

  • June 15, 2009
  • 1 reply
  • 1647 views

I have an online store, some of the image file names have a space in them.  This still displays fine in FireFox but not in IE.  I tried to replace the space with a %20 thinking that this will render the image in IE and it still does not show in IE but will show in FireFox w/ the %20.

Here is my code:

<cfset sImage3 = "#reReplace(SImage,' ', '%20 ', 'all')#" >
                <IMG SRC="#Trim(sImage3)#" BORDER="0" >

Any suggestions?

    This topic has been closed for replies.

    1 reply

    Inspiring
    June 15, 2009

    Instead of a regular expression, try using the built-in function, URLEncodedFormat:

    http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=functions_t-z_10.html

    It should do the trick for you.

    AJBJAuthor
    Inspiring
    June 15, 2009

    I changed the code to read:  <IMG SRC="product-images/small/#URLEncodedFormat(Trim(sImage2))#" BORDER="0">

    The image still only displays in FireFox but not in IE.

    When looking at the source for the image it reads the following:

    FireFox: http://lightsunlimitedinc.com/product-images/small/4404%20GR%2EJPG

    IE: http://lightsunlimitedinc.com/product-images/small/4404%20GR.JPG

    Inspiring
    June 15, 2009

    I was only able to see the image in Safari (Mac and PC). I could not see it in IE 8, IE 7, Firefox 3 (Win) and Google Chrome 1. In Firefox 3 on Windows, I got an error message:

    The image “http://lightsunlimitedinc.com/product-images/small/4404%20GR%2EJPG” cannot be displayed, because it contains errors.

    I then downloaded the image from Safari (since I could see it in this browser) and checked it's properties. According to the file information, the image was saved with the CMYK color space. This is not supported in most browsers and I believe that's the issue and not the file name's format.

    If you are able, I would recommend grabbing the above file/image from the server. Then, edit it in an image editing program such as Photoshop or Fireworks (ensuring that you save it with the RGB color space and not CMYK). Finally, upload it to the server, overwriting your existing image, and open the above URL in your browsers. You should now be able to see the image in Internet Explorer (IE does not support CMYK images) and other browsers.