Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

CFHTTP - verify file first

Participant ,
May 19, 2008 May 19, 2008
I am currently retrieveing files from another server via cfhttp. Occasionally, the files get renamed and my script throws an error. How can I verify if a file exists on a remote server before I make the cfhttp connection?
TOPICS
Advanced techniques
335
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , May 19, 2008 May 19, 2008
I had to deal with the same problem about a week ago.
Here's how I got around it:

<cftry>
<cfhttp method="head" name="testTheFile" url="myurl.html"></cfhttp>
<!--- If code reaches this point, File Exists --->
<cfcatch>
<!--- File does not exist --->
</cfcatch>
</cftry>
Translate
LEGEND ,
May 19, 2008 May 19, 2008
check the statuscode returned in the cfhttp structure: 200 means file is
there.

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 19, 2008 May 19, 2008
LATEST
I had to deal with the same problem about a week ago.
Here's how I got around it:

<cftry>
<cfhttp method="head" name="testTheFile" url="myurl.html"></cfhttp>
<!--- If code reaches this point, File Exists --->
<cfcatch>
<!--- File does not exist --->
</cfcatch>
</cftry>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources