Skip to main content
Known Participant
November 23, 2007
Pregunta

How to Check Images File Exist? in different server

  • November 23, 2007
  • 4 respuestas
  • 1083 visualizaciones
Hi,

I have 10 different coldfusion server.

for example 9 server is for the web application site - for example http://myserverone/studentweb

the other one is for images website, just for displaying student picture - for example http://myserverimage/studentpicture.
the purpose of this website is to display student picture that i store as gif files.


from my studentweb website i will call the images from studentpicture website as source for my image placeholder.
for example this is my code i'm calling form http://myserverone/studentweb website:

<img src=" http://myserverimage/studentpicture/#studentnumber#.gif" alt="" name="studentpicture" width="160" height="200">

my problem is, if there is no specific student picture in my studentpicture website, then the placeholder will display an X ( mean the images not found )

how do i prevent the X to display?
how do i using coldfusion or any kind of way to check if the images exist on that website ( different server ), so if the images is not found, i can display a default images? i can do this if i'm calling the website in the same server, but not using a different server.

this is like using other website images for your own personal website and sometimes the owner delete the images from their website, and i want to display my own images if that images been removed from the source website.

anyone have done this before?

thanks for suggestion and guide...

haire





    Este tema ha sido cerrado para respuestas.

    4 respuestas

    haireAutor
    Known Participant
    November 29, 2007
    yeah, that works fine. thanks for the info guys
    BKBK
    Community Expert
    Community Expert
    November 28, 2007
    1. Use CFHTTP with method="HEAD".
    2. See, if the HTTP status code is 200.


    The head-method is of course more efficient, as it doesn't need to "get" the message body. However, a status code of 200 is possible even when the requested image file is no longer on the server.

    haireAutor
    Known Participant
    November 26, 2007
    thanks,
    that what i'm looking for...
    Participating Frequently
    November 27, 2007
    1. Use CFHTTP with method="HEAD".
    2. See, if the HTTP status code is 200. If so, use remote Web-site for image.
    3. Otherwise, use some other URL for "default" image.
    Inspiring
    November 23, 2007
    <cfhttp> will be able to help you.
    check cfml reference or livedocs if you are not familiar with it.

    ---
    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com
    BKBK
    Community Expert
    Community Expert
    November 23, 2007
    Yes, cfhttp, but with some caveats. The following example is self-explanatory.