How can I know if a remote file exist?

Posted on 2004-11-13
Last Modified: 2013-12-20
How can i check in Coldfusion if exist the file: ""?
Question by:micba
    LVL 6

    Accepted Solution

    You could try downloading it using cfhttp:

    <cfhttp url="" method="GET">

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

    Expert Comment

    Do u mean remote as in on ur remote server - or ur talking abt some other site altogether ?

    Author Comment

    Thanks mosphat.
    Very good.

    Expert Comment

    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)>
    LVL 6

    Expert Comment


    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...

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    When deciding to adopt any help desk solutions many factors should be explored before taking decisions. This will change from business to another but in general there are some kind of rule of thumb. Here are some quick tips: Do we need only ticket…
    This article provides a case study on how our local youth baseball league deployed a new website, including the platform selection, implementation and benefits to the league.
    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 integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…

    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

    15 Experts available now in Live!

    Get 1:1 Help Now