[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How can I know if a remote file exist?

Posted on 2004-11-13
5
Medium Priority
?
1,683 Views
Last Modified: 2013-12-20
Hello,
How can i check in Coldfusion if exist the file: "www.mysite.com/pic.jpg"?
Thanks.
0
Comment
Question by:micba
5 Comments
 
LVL 6

Accepted Solution

by:
mosphat earned 2000 total points
ID: 12573392
You could try downloading it using cfhttp:

<cfhttp url="http://www.mysite.com/pic.jpg" method="GET">

<cfif cfhttp.responseheader.status_code eq 404 or not listfindnocase("image/jpg,image/jpeg", cfhttp.responseheader["content-type"])>
  file not there
<cfelse>
  file there
</cfif>
0
 
LVL 17

Expert Comment

by:anandkp
ID: 12573731
Do u mean remote as in on ur remote server - or ur talking abt some other site altogether ?
0
 

Author Comment

by:micba
ID: 12573847
Thanks mosphat.
Very good.
0
 

Expert Comment

by:holosimexchange
ID: 14259655
You could use the FileExists function.
In the CFIF tag, call the FileExists function and use the ABSOLUTE PATH for the file.
Although I've never actually gotten this to work properly, it's supposed to work.

<cfif FileExists(idPhoto)>
0
 
LVL 6

Expert Comment

by:mosphat
ID: 14259762
holosimexchange,

FileExists() only works for local files, like C:\blah.txt. You just need to put in the full path to the file. I don't see how you cannot get it to work properly...
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

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…
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 …
The purpose of this video is to demonstrate how to exclude a particular blog category from the main blog page. This is can be used when a category already has its own tab, or you simply want certain types of posts not to show up on the main blog. …
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…
Suggested Courses
Course of the Month19 days, 13 hours left to enroll

872 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