Solved

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

Posted on 2003-11-14
6
186 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 

Accepted Solution

by:
CarlsonCo earned 250 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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

726 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