Strange FileUpload() Behavior

I’m seeing some strange behavior from FileUpload() when the destination doesn’t have an extension. Consider this:

[CFIf IsDefined(‘Form.File’)]
[cfscript]
Dest=‘/var/www/files/dir1/dir2/myfilename’;
CFFile=FileUpload(FileField=Form[‘file’],Destination=Dest,NameConflict=‘error’);
Dump(CFFile);
[/cfscript]
[/CFIf]
[form action=“test” method=“post” enctype=“multipart/form-data”]
[input name=“file” type=“file” /]
[input type=submit]
[/form]

If /var/www/files/dir1/dir2 doesn’t exist, it’ll error (which is the correct behavior), but if it exists, it instead, because “myfilename” doesn’t have an extension, creates the directory “myfilename” under dir2 and then uses the original form field filename and store a file under the new directory. This is my directory structure before the upload:

tomcat@localhost:/var/www/files$ find .
.
./dir1
./dir1/dir2

And here it is after the upload (2723.pdf being the file I uploaded):

tomcat@localhost:/var/www/files$ find .
.
./dir1
./dir1/dir2
./dir1/dir2/myfilename
./dir1/dir2/myfilename/2723.pdf

I would have expected that if the directory “/var/www/files/dir1/dir2/myfilename” didn’t exist, it should put the file under dir2 with the name “myfilename”.

So, it appears that there’s no way to upload to a file that has no extension. If I specify the filename as “myfilename.” (with a period at the end), then it’ll create the file with a period at the end, but that’s a different file than a file without extension.

The reason why I ask is because I am writing an upload routine where all information, including the location of files, is kept in a database table and the only information stored on the file system is the identity column from my database table. I can get around this probably by just giving all my uploaded files an extension of “.bin” or something, but I’m wondering if this is the intended behavior. It seems odd that Lucee would take the liberty of creating a directory before uploading the file.

Thanks,
Ross.

OS: Debian 11
Java Version: 11.0.15
Tomcat Version: 9.0.43-2
Lucee Version: 5.3.9.141

i think that works as expected. If you read the Lucee docs for fileuploads() the destination should be a path to a directory OR file. Cfdocs and adobe even doesn’t talk about filenames in their docs at all, just a path of directory. Thus, a string defining a path (without any file extension) will be obviously interpreted as a directory. You need to make a workaround to make that work.

1 Like

@Ross_Naheedy If the destination file has no extension, it creates a new directory and saves the file with the original form field filename in lucee.

So please file an incompatibility ticket in Jira: https://luceeserver.atlassian.net/

1 Like