Skip to main content
Known Participant
September 24, 2011
Answered

cffileupload - how do I cfmail list of files uploaded

  • September 24, 2011
  • 2 replies
  • 3290 views

I have the cffileupload working correcly and being processing the files putting them into a directory and inserting the filename, filesize, etc into an sql table. I need to send ONE email with a listing of the files uploaded, not an email after each file is processed.

Any help is appreciated

Thanks,

sitedev

    This topic has been closed for replies.
    Correct answer BKBK

    sitedev wrote:

    I have added   at the end of the processing page where it inserts the records into the database. It sends an email for each file uploaded. I only want one email with a listing of all files uploaded during that one upload submission.

    You could use the following trick to create the list of uploaded files. At the beginning of the page containing the cffileupload tag, initialize a session variable to hold the list of uploaded files, thus

    <cfset session.uploadedFileList = "">

    In the page containing the tag <cffile action = "uploadAll">, place the following code after the tag:

    <cfset session.uploadedFileList = listappend(session.uploadedFileList,cffile.serverfile)>

    After the upload process, the list of uploaded files, session.uploadedFileList, will be available to every page.

    2 replies

    BKBK
    Community Expert
    Community Expert
    September 24, 2011

    <cffileupload />

    <!--- My upload file is c:\uploads (assumed empty before upload) --->

    <cfdirectory action="list" directory="c:\uploads" name="uploadDir" filter="*.*">

    <!--- List of all files currently in upload folder. My choice of list delimiter is " | " --->

    <cfset fileList = valueList(uploadDir.name," | ")>

    <cfoutput>#fileList#</cfoutput>

    <cfmail>

        <!--- send fileList  --->

    </cfmail>

    sitedevAuthor
    Known Participant
    September 24, 2011

    Thanks for the response. There are other files in the folder from previous uploads. I guess I could do this and filter by date and then output the list in then move the files from the temp folder to the final folder. Thanks for the pointers.

    sitedev

    Inspiring
    September 24, 2011

    What have you tried and how re the results different than you expect?

    sitedevAuthor
    Known Participant
    September 24, 2011

    I have added at the end of the processing page where it inserts the records into the database. It sends an email for each file uploaded. I only want one email with a listing of all files uploaded during that one upload submission.

    Thanks…

    Inspiring
    September 24, 2011

    So you are able to process these files individually.  Good.  Instead of sending mail at this point, add the filename to a list.  Then, when all the files have been processed, mail the list.