Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
You've missed the hashes around "variables.lCaseFileName".
Copy link to clipboard
Copied
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#")>
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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