I'm using Nginx for a Linux server and I have this folder /usr/local/openresty/nginx/webfolder/img
where I want nginx to save my uploaded image files.
So, this is what I did:
1) I changed the owner of the directory to www-data
user in www-data
group:
chown -R www-data:www-data /usr/local/openresty/nginx/webfolder/img
2) Then I updated the permissions of the directory:
sudo chmod 0600 /usr/local/openresty/nginx/webfolder/img
Lua upload err part (where I log the err):
fileToSave, errMessage = io.open(savefiletarget, "w+b")
if not fileToSave then
--ngx.say("failed to open file ", savefiletarget)
ngx.log(ngx.NOTICE,'failed to save file : '..savefiletarget..' reason: '..errMessage);
ngx.say('{"filename" : "'..filenametosave..'","status" : 0 ,"message":"failed to open file"}')
return
end
Right now my error log still shows Permission Denied
when I try to upload the file.
I assume www-data
is the user that nginx uses right? So why I'm not able to still write the file?