This code uploads files from two different file in...
# cfml-general
a
This code uploads files from two different file input fields and both upload multiple files. It does a cfloop to iterate over the values of the lists of files in each field. The issue I’m facing is that cffile action=“upload” uploads the same image for both fields. When using cfimage it uploads images correctly, but cfimage is very slow in performance compared to cffile. Can anyone point out what I’m doing wrong? I’ve also tried cffile action=“uploadall” but it is also not working correctly, both cffile action=“uploadall” uploads all the files in the current request. I’m using two multiple file fields because need to rename files according to the fields where they are coming from. The code is in the thread.
cffile-test-file.cfm
a
That's a big dump of code and looks like a lot of it is commented out so hard to look at and spot issues.
However this is wrong:
Copy code
<cffile
  action="upload"
  destination="#uploadFolder#"
  nameconflict="MakeUnique"
  accept="image/png,image/jpg,image/jpeg"
  strict="true"
  source="#item#"
>
source
attribute is used for copying files
not for uploads
a
@aliaspooryorik got it, but the source is not copying the files correctly.
g
I have no idea - bit I wonder (aloud) is it a "request" thing? Would it work if you use separate AJAX calls for each file?
a
@gavinbaumanis by request I mean it can be form POST request and AJAX request, I’ve tested it with Postman too. If I use a single input file field it works fine.
g
Sorry if I wasn't clear. Initially my thought was that within a Coldfusion "request"... I have done a little googling and while an older post (so it might be different now in current versions of ACF and Lucee) that CFFILE is unable to rpcoess multiple files from multiple form inputs. So that would lead me to NOT use cffile for the task at hand. Via google - I fouind this on @ben’s blog - which might be the answer you're after or perhaps point you in the direction of a solution; https://www.bennadel.com/blog/1117-ask-ben-uploading-multiple-files-using-coldfusion.htm
a
a
@aliaspooryorik @gavinbaumanis Sorry, for the confusion. Let me try again by attaching some screenshots.