Copy link to clipboard
Copied
Zip files get uploaded to my server. The zip file has the same name as the folder within it, only with a ".zip" extension of course. There is also an html file within the folder, but not named "quite" the same. Example:
Zip file= "Get_Well_Soon_HTML.zip"
Folder name="Get_Well_Soon_HTML"
File name="Get_Well_Soon.html"
I want to put the name of the html file in my database when the file is uploaded. I can get the folder name easily, since it's the same as the zip file, I just use File.ClientFileName. How can automatically determine the html file's name?
Copy link to clipboard
Copied
If you think of the file name as a list delimited by "." you can easily use list functions
File.ClientFileName
Is there a reason you are using the ClientXX and not ServerXX variables? Typically you want information about a file's name and location on the server not the client. Depending on the settings you use for cffile, those values are not always the same. Also, FILE is deprecated. Use CFFILE (or cffile's "result" atribute) instead.
Copy link to clipboard
Copied
If your naming conventions are always the same then you could try stripping off the _HTML from the name of the folder, and replace it with .html to get the file name.
<cfset htmlFileName = ReplaceNoCase(folderName, '_HTML', '.html')
Copy link to clipboard
Copied
Ah, I missed the part about "html" being part of the name not extension. Good catch.
Copy link to clipboard
Copied
Yep, the replacenocase worked like a dream. Thanks!
Copy link to clipboard
Copied
Just curious. Did you see the comment cffile ClientXX versus ServerXX variables? (I have never used them myself)
Copy link to clipboard
Copied
I did, and I appreciate the information, but it's an old habit that I've never had an issue with. It still works in this instance as well...
Copy link to clipboard
Copied
Having seen several posts where clientXX variables were used blindly, without understanding what they represent, I just had to ask ...
Copy link to clipboard
Copied
I'm pretty rusty with CF, but that's one of the basics I actually do know
Copy link to clipboard
Copied
Ah, okay. Given that the forums are about code problems, when you see something out of the ordinary (ie potentially problematic) it is practically instinct to comment on it 😉