Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can easily abstract it with a user defined function.</p> <pre><code>&lt;cffunction name="fileuploader"&gt; &lt;cfargument name="formfield" required="yes" hint="form field that contains the uploaded file"&gt; &lt;cfargument name="dest" required="yes" hint="folder to save file. relative to web root"&gt; &lt;cfargument name="conflict" required="no" type="string" default="MakeUnique"&gt; &lt;cfargument name="mimeTypesList" required="no" type="string" hint="mime types allowed to be uploaded" default="image/jpg,image/jpeg,image/gif,image/png,application/pdf,application/excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/vnd.ms-excel,image/pjpeg"&gt; &lt;cffile action="upload" fileField="#arguments.formField#" destination="#arguments.dest#" accept="#arguments.mimeTypesList#" nameConflict="#arguments.conflict#"&gt; &lt;cfreturn cffile&gt; &lt;/cffunction&gt; </code></pre> <p>And then use it in cfscript:</p> <pre><code>&lt;cfscript&gt; // NOTE: because of how cffile works, put the form field with the file in quotes. result = fileUploader("FORM.myfield", myDestPath); WriteOutput(result.fileWasSaved); &lt;/cfscript&gt; </code></pre> <p>Note: I would be very careful how you rename this function in case Adobe does include this functionality down the road.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload