But it's failing the syntax check. I might be clim...
# cfml-general
p
But it's failing the syntax check. I might be climbing the wrong ladder.
s
cffile( filefield="form.upload_file", nameconflict="overwrite", destination=TempUploadPath, action="Upload" );
p
Thanks Scott.
s
when in doubt... https://cfscript.me/
p
remove quote marks around form.upload_file.
a
Yeah I'm sorry but using the generic tag-in-script syntax where there's function to do it is not great
lol
a
haha, snap
cfscript.me turns out some pretty dire code, in my limited experience
s
cffileupload is deprecated though, so definitely don't use that
a
It just transliterates tags to tags-in-script by the looks, and that's not generally how one would do it
s
Is there a sepecific advantage to using fileupload() vs cffile(action="upload",...) ?
(other than that's the way Adam likes it best?)
p
I don’t think so.
a
The syntax for
cffile(etc)
is leveraging the "fill in all the missing bits and pieces" generic approach that the CF Team lazy-arsed onto us. It's a weirdo construct that looks like a function but actually isn't, and is a shit way of coding. EG:
someGeneralFunction(variant="string")
is just bad practice compared to
specificFunction(getOnWithIt)
So yer not really supposed to use the "fill in all the missing bits and pieces" approach when there's already a "native" approach. Using a function built for the task at hand.
And exactly how many redundant "cf" instances do you really want littering your code? Ugh.
I see
cffile
in code and am going "what's a
cffile
compared to some other sort of file? You don't have shitfuckery like that in any other language.
s
Just to be clear, I would agree that if there is a specific function, I would prefer to use that, and I don't like having multiple ways to do the same thing, but I chock that up to backwards compatibility, etc.... but other than syntax preferences, is it slightly faster or anything to use fileupload()?
a
(and I was among a bunch of people who said this to Adobe at the time they thought to take this approach - in the PR programme for I guess CF11? - and they just shrugged and went "well it's done now". Useless)
I would not imagine so, no. Not meaningfully so, anyhow
Compiled code execution is measured in like microseconds. File operations are measured in seconds or milliseconds at best. Multiple orders of magnitude difference.
s
I would imagine that both methods would compile into the same class file whether you use fileupload() cffile(action='upload'...), or <cffile action="upload"....... but who knows
a
You'd likely see more performance difference by taking one byte out of the file yer uploading than would possibly be the difference between which function/statement one used to copy the file from the web server temp dir to the target dir.
g
Related : but not necessarily the same thing... In our code base I have seen; (example only not necessarily even valid code) cffile(some args here) file(some args here) cffile attributesAndValues : no ()'s What are these - with respect to; Are they the same thing just in different formats? @Adam Cameron: (Well anyone really) For my own education / clarification... In terms of THIS discussion's original intent - I assume the "_*native*_" function is / are: fileUpload / fileRead / etc? (https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-functions/functions-by-category/file-functions.html) As opposed to the do "eveything" by changing an attribute / argument of "cffile"?
s
Yes the “native” functions are https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-functions/functions-by-category/file-functions.html In essence, they do the same thing.
But Adam has a general dislike for the notion of all tags being easily invoked as functions in cfscript by using the tagname as the function name and putting the tags attributes in the function arguments
Particularly when there is a perfectly good coldfusion function that can be used
( at least that was my interpretation)
I can kind off see an argument for the tags as functions method… because it’s easier to remember a single set of attributes for a particular tag/tag as function than to try and remember two different ways to do the same thing… i like consistency. But then I don’t really ever do file operations in tag syntax anymore and would likely use the file functions either way and just never use cffile
👍🏼 1