?
Solved

How to detect if  a file doesn't exist on a remote website.

Posted on 2003-11-14
6
Medium Priority
?
196 Views
Last Modified: 2013-12-24
I have an image showing currency rateson my site and it is  updated  hourly on a remote site. However the other site is having problems and sometimes the graphic is not existant.

I don't want a broken link appearing on my site. Is there anyway I can detect whether the graphic is there or mot?
0
Comment
Question by:kjuliff
  • 4
6 Comments
 

Expert Comment

by:CarlsonCo
ID: 9749866
Use the FileExists() function.
0
 
LVL 1

Author Comment

by:kjuliff
ID: 9749934
But the file is not in a directory at my site.
0
 

Expert Comment

by:CarlsonCo
ID: 9749981
Oops, I see what you mean.  Hmmm...I've done this before in Java.  Let me check into it.
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Accepted Solution

by:
CarlsonCo earned 750 total points
ID: 9750044
This should work:

<cfset ImageExists = "True">
<cftry>
      <cfhttp url="http://i.a.cnn.net/cnn/.element/img/1.1/logo/logo.gif"
            method="GET"
            resolveurl="Yes"
            throwOnError="Yes"/>
<cfcatch type="Any">
      <cfset ImageExists = "False">
</cfcatch>
</cftry>
<br>Image exists? #ImageExists#<br>

0
 
LVL 17

Expert Comment

by:anandkp
ID: 9752912
yes CFHTTP shld help u with it

But i wld say - since ur updating ur site every hour ... sooner or later the user will get the real image - right !

so to avoid teh errors popping up - use CFERROR to show friendly error messages & let the user know that in few minutes he can have the image - which is not currently updated on the server.

u can also change the updates from hourly to every 10 minutes so as to avoid the error ratio !

just a thought !
0
 

Expert Comment

by:CarlsonCo
ID: 9764126
There is a disadvantage to the method I suggested in that it downloads the image to your Web server as well as your clients browser.  That added bandwidth takes a hit on your Web site and doubly on the source host.  Of course, it depends on the size of the image.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

750 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question