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

FielExists

Explorer ,
Apr 12, 2011 Apr 12, 2011

I have files with upper and lower case in the share.  and i need to display on the page so i converted all into lower case then check to see if it exists but it seem dosen't work.


<cfset variables.lCaseFileName = LCASE(trim(variables.filename)) />
#variables.lCaseFileName# displayed all files in lower case


<cfif FileExists("#path#/variables.lCaseFileName")>
found
<cfelse>
no
</cfif>

thanks

TOPICS
Advanced techniques
628
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
Guide ,
Apr 12, 2011 Apr 12, 2011

You've missed the hashes around "variables.lCaseFileName".

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 ,
Apr 13, 2011 Apr 13, 2011

oh i missed that here but i have it in my code but it not working.  Is there any other sugesstion?

<cfif FileExists("#path#/#variables.lCaseFileName#")>

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
LEGEND ,
Apr 13, 2011 Apr 13, 2011

What do you mean by "doesn't seem to work"?  What happens instead of it working?  Does it error?  Does it suggest "no" when you expect to see "found"?

If you output the value of #path#/#variables.lCaseFileName#, is that the full path to the file (incl. drive letter)?  You should be able to copy that value from the screen and paste it into a file explorer on the server, and the file should exist.

--

Adam

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 ,
Apr 13, 2011 Apr 13, 2011

no error,  it supposed to fshow "Found" but it shows  "No".  It is in unit system then no driver letters.

i have the image files are: abc102.gif, cde105.gif, BEC204.gif.  with the code i have, i expected BEC204 supposed to show "Found" instead of "No"

the path is correct because i try to change it to all lcase then it works fine. when i output the

#path#/#variables.lCaseFileName# it shows all path with all filenames, but it shows /mypath/bec204.jpg, I don't have bec204.gif in the folder instead of BEC204.gif that's why it can't find it.  I don't know to handle this situation?

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
LEGEND ,
Apr 13, 2011 Apr 13, 2011
LATEST

You mean Unix rather than "Unit", yeah?  I presume so.

Well *nix is case sensitive, so you simply can't lowercase a file name and expect it to be found if the actual file name has mixed case.  As far as *nix is concerned, foo.txt is a different file from Foo.txt or FOO.txt: all three can quite happily co-exist in the same directory.

If you want to find BEC204.gif, then that's what you need to look for.  Not bec204.gif.  Because on *nix that's a completely different file, so you shouldn't expect the two to match: they are not the same thing.

--

Adam

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