Trying to upload a file with opening new folder.
But laravel returns error like below.
$destinationPath = public_path() . $folderName;
if(!is_dir(public_path().'/uploads')) {
mkdir(public_path().'/uploads', 0755, true);
}
$mkdir = mkdir(public_path().'/uploads/'.$unique, 0755, true);
$success = file_put_contents(public_path().'/uploads/'.$unique."/".$filename, $file);
I used;
sudo chown -R nginx:nginx public/uploads
sudo chown -R root:root public/uploads
sudo chown -R $USER:$USER public/uploads
But nothing changed.
What’s wrong?
Is laravel’s nginx user different? How can I learn?
2
Answers
you should check the Nginx user inside your Nginx config file.it can be found at
/etc/nginx/nginx.conf
and likely set touser www-data;
Try running the command
This command should work. If now let me know.