Can Lucee mimic Coldfusion's file upload?

This is my first post so I apologize in advance if it’s missing any info.

I’m converting a Coldfusion project to Lucee, and ran into an issue when uploading files. With Lucee, the destination value needs a filename, otherwise it creates a subdirectory and places the file in it.

Is there a way to make Lucee work like Coldfusion does with file uploads? (just give it a destination folder) Otherwise, I have a lot of code to update. Thank you for any feedback.

hey @felix welcome to Lucee!

Could you share the problematic code snippet you are using to process a file upload? the forum supports markdown, do you can wrap code in three backticks to format it

One question, does the target directory exist?

It really doesn’t matter for this question, but please always mention which version of Lucee you are using

Thanks @Zackster

We are running Lucee version 6.2.1.122. Here’s a snippet of current Coldfusion code:

<cffile action="upload" fileField="imageField" destination="/path/to/images/folder" nameConflict="makeUnique">

The target directory does exist, and the code always check if it does, just in case. With Coldfusion, the new image would be saved to the mentioned destination, but in Lucee it creates a new directory and saves the image in it. From what I see in the docs, I have to specify the file name in order for Lucee to save the image in the given destination folder.

<cffile action="upload" fileField="imageField" destination="/path/to/images/folder/new_file_name" nameConflict="makeUnique">

Since I don’t know which type of file the users will upload, I first create a temp file with their upload, then rename it to “cffile.clientFile”.

I know it’s not a lot of changes, but we have a very large codebase and I would need to update the code in a lot of different places. I’m curious of there’s a way to make Lucee handle uploads the same way Coldfusion does. Thanks for any input!

I put together a test repo, there’s more context need for your error

Could it be a mapping is conflicting with a file system path, as Lucee resolves mappings before file system

Anyway, here’s my working test cases, can you fork and show me the issue?

If you haven’t already., it would be great if you could support the Lucee project :slight_smile: