Cffile upload problem in ubunto

Hi,

I’m on ubuntu 18.04 and attempted to upload an image file via cffile upload from a FORM submission.

Code:

<cffile action="upload"
   destination="/home2/userX/lucee/www"
   filefield="#FORM.picField#">

Error msg:
attribute destination has an invalid value
[/home2/userX/lucee/www/myhandsome.jpg], directory [/home2/userX/lucee/www] doesn’t exist
Stacktrace The Error Occurred in
/var/www/myfileupldoad.cfm: line 72

but directory, /home2/userX/lucee/www DOES exist and it’s the FULL path.

And the lucee is a docker image, lucee52.

Thoughts?

Thanks.

It exists… in the docker image?

1 Like

This is more than likely a permissions issue.

Check and make sure that Lucee can CRUD files in that directory.

1 Like

More specifically you can run <cfdump var="#getFileInfo("/home2/userX/lucee/www")#"> and it will have info such as canRead, canWrite make sure those are both true first. If they are false then you need to give the user that lucee is running as write permission to that directory.

Pete Freitag
https://foundeo.com/

2 Likes

Thank you all for your informative responses, I’ll try Pete’s advice first.

Debugging is a good suggestion.

sorry for late response, definitely.

Ok, I’m getting back to cf file manipulation tags under Lucee container image ( lucee52 ) for linux/ubunto.
Before I continue, let me take a sec to thank all those who have been graciously helpful for 2018.
currently, for cffile action=“write”, the file is written to the default /var/www folder,
<cffile action="write" file="#ExpandPath('./myfile.doc')#" output="#mybinarydatastring#">
that is, the above code creates /var/www/myfile.doc
which is not web / user accessible. attempted to use cffile action=“copy” to copy it to my {web-root-folder} failed.
<cffile action="copy" source=#ExpandPath('./myfile.doc')# destination="/home/userX/lucee/www">
err msg to the effect, “can’t copy … no file or directory” but I believe the cffile write action was successful.

Attempt to cffile write to /home/userX/lucee/www folder directory (hard code) resulted in “parent directory does not exist” error.

What else can we try?
Yep, cfheader/cfcontent is an alternative, it seems to work.

Thanks.

you would have to place users in the same group as the root directory and the application running.

if /home/userX/lucee/www/ is owned by lucee.lucee
then your web server would need to be able to read /home/userX/lucee/www/
if then file in question above is in /var/www/ with the name myfile.doc
then the web server needs to be able to read files in /var/www/
the file permission with lucee may have higher / stricter permissions than the web server

you can try to change the user lucee runs as, you can additionally add lucee’s user / group to the user / owner of the /var/www

You can view who owns the files by doing a ls -lt

for Ubuntu / Debian /var/www/ is usually www-data
for Redhat Linux / Centos /var/www/html/ is apache.apache

you can chown the files - Redhat Linux / Centos
chown -R apache.apache /var/www/html

For Ubuntu / Debian
chown -R www-data.www-data /var/www/html/

Thanks Terry, it’s been resolved a while ago. I’ll mark post status in the future.

Just a note to addon. Tomcat 8.5 changed UMASK to 0027. You can edit the Catalina.sh file or setenv.sh file to change back to 0022. I hit this permission change when I created a new web VM with UBUNTU 18.04 and latest Lucee/Apache. By default all files were written lucee.lucee and Apache was using www-data. You could also add adduser to group.

Good to know, thank you.