ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 17th, 2003, 07:52 AM
gotspy's Avatar
gotspy gotspy is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Buffalo, NY
Posts: 156 gotspy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 59 m 53 sec
Reputation Power: 11
How do I know if a file is there?

I am trying to check to see if a specific file in a directory is there before I allow the user to move on.

I'm looking for a way to basically say,
<cfif #file# exists>
<img src="#file#">
<cfelse>
You need to upload the file.
</cfif>

I looked at the CFFILE and CFDIRECTORY tags, and they don't seem to have a way to check like this.

I looked into the list feature of CFDirectory, but I thought there must be a better way than to retrieve the list of files, then look through the list to see if the file name is there.

Thanks for the help.
__________________
Forget Milk!
Gotspy?

www.gotspy.com

Reply With Quote
  #2  
Old December 17th, 2003, 09:48 AM
DeepDown DeepDown is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Netherlands
Posts: 99 DeepDown User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 1 m 8 sec
Reputation Power: 10
hopefully the following snippet helps you out:

<!--- Absolute path + filname to the expected file --->
<cfset myFile = "C:\bogus.txt">

<cfif FileExists(myFile)>
<cfoutput>#myFile#</cfoutput> EXISTS!!!
<cfelse>
<cfoutput>#myFile#</cfoutput> DOES NOT EXIST!!!
</cfif>
__________________
** Don't expect me to code your needs, but if I am able to help, I'm willing. Shout, grab and use the hand!
** Man can no more own the land we walk upon, as they can lay claim on the air that we breath
** DeepDown I'm addicted to structures.... ohw and music
** Almost forgot I had an account here [*o*]

Last edited by DeepDown : December 17th, 2003 at 09:53 AM.

Reply With Quote
  #3  
Old December 17th, 2003, 11:07 AM
gotspy's Avatar
gotspy gotspy is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Buffalo, NY
Posts: 156 gotspy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 59 m 53 sec
Reputation Power: 11
Wow,
Look at that! the FileExists function is right there on Page 206 of the Cold Fusion5 Language Refrence! How did I miss that!?!?

Thanks! I feel pretty stupid now. I use that book almost every day, and don't remember ever seeing that function.

THANKS!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > How do I know if a file is there?

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap