Cffile not spawing variable cffile.serverfile containing file name

I’m using a cffile tag to upload an image file from a form. The upload bit works flawlessly, including the rename for uniqueness. However I can’t get the tag to spawn the variable cffile.serverfile as I think it should if the file has to be renamed. I’ve got a cfparam tag in there just to make sure the variable exists so it doesn’t throw an error with my code if the variable doesn’t exist, but every time the variable ends up blank.

What am I doing wrong here please folks? Any clues would be greatly appreciated. Thanks in advance.

                    <cfoutput>
                        <cfparam name="form.fileUpload" default="">

                        <cfif len(trim(form.fileUpload))>
                            <cffile action="upload" fileField="fileUpload" destination="C:\path-redacted" allowedExtensions="PNG" nameconflict="makeunique" result="uploadresult">
                            <div class="ui inverted mini uploadimageresult modal">
                                <div class="header">UPLOAD IMAGE</div>
                                <div class="content">                        
                                    
                                    <p>Thankyou, image has been uploaded.</p>
                                    <cfparam name=cffile.serverfile default="">
                                    
                                    <cfif #cffile.serverfile# is "">
                                        <p>Image File Name:</p>
                                        <p>uploaded/NameOfFileAsUploaded.png</p>
                                    <cfelse>
                                        <p>Image File Name (renamed for uniqueness):</p>
                                        <p>uploaded/#cffile.serverfile#</p>
                                    </cfif>
                                </div>
                                <div class="actions">
                                <div class="ui green approve button">OK</div>
                                </div>
                            </div>
                            <script type="text/javascript">
                                $('.inverted.mini.uploadimageresult.modal')
                                .modal('show')
                                ;
                            </script>
                        </cfif> 

try dumping out the uploadresult variable?

1 Like

Using the variable uploadresult.serverfile did the trick, thanks!