Solved

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

Posted on 2003-11-14
6
183 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
Comment Utility
Use the FileExists() function.
0
 
LVL 1

Author Comment

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

Expert Comment

by:CarlsonCo
Comment Utility
Oops, I see what you mean.  Hmmm...I've done this before in Java.  Let me check into it.
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Accepted Solution

by:
CarlsonCo earned 250 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
This video discusses moving either the default database or any database to a new volume.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

728 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now