what is wrong i am doing here <cfloop array="#f...
# lucee
g
what is wrong i am doing here <cfloop array="#formfields.uploadedFiles#" index="i"> <cfset cffile = UploadFile( FileField = "i", destination = filePath )> <cfset actualFile = cffile.serverDirectory & "/" & cffile.serverFileName> </cfloop>, i tried "#i#", uploadedFiles[i], #uploadFiles[i]#,"uploadedFiles[i]", but nothing seems to be surpassing the upload properly, i am using the uploadFile function deom cflib.org , if i pass a single file, it works, with "uploadFiles", but with array its causing a trouble
i
<cfloop array="#formfields.uploadedFiles#" index="currentFileField">
<cfset cffile = UploadFile(
FileField = currentFileField,
destination = filePath
)>
<cfset actualFile = cffile.serverDirectory & "/" & cffile.serverFileName>
</cfloop>
💯 1
is it the "i" for FileField? In the loop. you use "i" for index, but inside that loop it would be just i the variable
I had code bot reformat that code for me. Also, I used the code button to format the code for you. ;-)
I would also check if the array is actually an array and is running multiple time by dumping inside the loop or something
g
ok, i will try that
a
Stylistically,
i
is a pretty terrible name for a variable that holds form field names.
m
scribbles note: use letter j next time
🤣 1
a
I see you there, Tom.
q
Real programmers use "x" for their variable names.
i
Real programmers strive to make everything as hard to understand as possible:
<cfloop array="#formfields.uploadedFiles#" index="x">
<cfscript>
try {
ArrayAppend(y, ArrayLen(z) ? CreateObject("java", "java.lang.String").init("") : z[1]);
for (i = 1; i <= ListLen(y[1], ','); i++) {
a = ListGetAt(y[1], i, ',');
if (IsSimpleValue(a)) {
if (REFindNoCase("^[a-zA-Z]:", a)) {
b = a;
} else {
b = ExpandPath(a);
}
if (DirectoryExists(b)) {
f = b;
break;
}
}
}
} catch (any e) {
f = GetTempDirectory();
}
param name="f" default="#GetDirectoryFromPath(GetCurrentTemplatePath())#";
</cfscript>
<cfset p = x>
<cftry>
<cffile action="upload" filefield="#p#" destination="#f#" nameconflict="overwrite" result="r">
<cfcatch type="any">
<cfset r = {serverDirectory: f, serverFileName: "error"}>
</cfcatch>
</cftry>
<cfset z = ListAppend(z, r.serverDirectory & "/" & r.serverFileName)>
</cfloop>
a
"Real" programmers probably also erroneously describe themselves as 10x. And are wrong. And dicks.
💯 1
q
10x? pfft. lightweight! 100x or better is my motto
🤣 2