Permissions 775?
Unable to write in the "public/images" directory on macbook
Hello, i'm trying to upload image but got issue about permissions.
public function postBook(Request $request)
{
$image = $request->file('cover');
$new_name = rand() . '.' . $image->getClientOriginalExtension();
$image->move(public_path('images'), $new_name);
dd($new_name);
return redirect('/admin/add-book-manually');
}
And i have this following error
Unable to write in the "/Users/makeba/Documents/Others_Projects/beugue_lire/public/images" directory
Thanks in advance
Nope, that would be bad idea. Write to storage folder and use storage:link artisan command to make it public.
i try it but same issue @bugsysha
What are the permissions for storage folder?
@bugsysha 755 as permissions
Have you tried 775?
Yes i already try 775 same error @bugsysha
Then there is nothing left but to try 777 :D
Isn't there Laravel built in logic for file upload?
i also try 777 @bugsysha same error
Post ls -la of whole Laravel project and public folder.
i did it, and there is the result @bugsysha
ā beugue_lire git:(develop) ā ls -la
total 1432
drwxr-xr-x@ 32 makeba staff 1024 Dec 3 21:56 .
drwxr-xr-x 19 makeba staff 608 Dec 3 21:56 ..
-rw-r--r--@ 1 makeba staff 8196 Dec 3 21:58 .DS_Store
-rw-r--r-- 1 makeba staff 220 Oct 6 22:46 .editorconfig
-rw-r--r-- 1 makeba staff 793 Nov 27 15:46 .env
-rw-r--r-- 1 makeba staff 835 Nov 27 15:41 .env-prod
-rw-r--r-- 1 makeba staff 793 Nov 25 23:10 .env.example
-rw-r--r-- 1 makeba staff 251 Oct 27 05:23 .eslintrc.js
drwxr-xr-x 14 makeba staff 448 Dec 4 22:49 .git
-rw-r--r-- 1 makeba staff 111 Oct 6 22:46 .gitattributes
-rw-r--r-- 1 makeba staff 163 Oct 6 22:46 .gitignore
-rw-r--r-- 1 makeba staff 175 Nov 25 23:21 .htaccess
-rw-r--r-- 1 makeba staff 242 Oct 6 22:46 .styleci.yml
drwxr-xr-x 11 makeba staff 352 Nov 20 23:20 app
-rw-r--r-- 1 makeba staff 1686 Oct 6 22:46 artisan
drwxr-xr-x 4 makeba staff 128 Oct 6 22:46 bootstrap
-rw-r--r-- 1 makeba staff 1531 Oct 21 15:41 composer.json
-rw-r--r-- 1 makeba staff 177947 Oct 21 15:42 composer.lock
drwxr-xr-x 15 makeba staff 480 Nov 27 16:07 config
drwxr-xr-x 6 makeba staff 192 Oct 6 22:46 database
drwxr-xr-x 756 makeba staff 24192 Nov 12 15:55 node_modules
-rw-r--r-- 1 makeba staff 460304 Nov 12 15:55 package-lock.json
-rw-r--r-- 1 makeba staff 1365 Oct 27 05:22 package.json
-rw-r--r-- 1 makeba staff 1156 Oct 6 22:46 phpunit.xml
drwxr-xr-x 13 777 staff 416 Dec 3 21:56 public
drwxr-xr-x 7 makeba staff 224 Oct 10 18:12 resources
drwxr-xr-x 6 makeba staff 192 Oct 6 22:46 routes
-rw-r--r-- 1 makeba staff 563 Oct 6 22:46 server.php
drwxr-xr-x 5 makeba staff 160 Oct 6 22:46 storage
drwxr-xr-x 6 makeba staff 192 Oct 6 22:46 tests
drwxr-xr-x 42 makeba staff 1344 Oct 21 15:42 vendor
-rw-r--r-- 1 makeba staff 905 Nov 28 09:53 webpack.mix.js
do you have an images folder? what are its permissions?
Yes @snapey i have an images folder and its permissions is 777
You have wrong owner for public folder. Run chown -R makeba public.
your public folder is owned by someone called 777 and the permissions are 755
you seem to have chown and chmod mixed up. Possibly the same for the images folder
Ah my bad
And chmod -R 777 public for permissions. Or try with less like 775 or 755 after chown.
i try both but same error @bugsysha
Post new ls -la for both folders.
@bugsysha the result is
otal 1432
drwxr-xr-x@ 32 makeba staff 1024 Dec 3 21:56 .
drwxr-xr-x 19 makeba staff 608 Dec 3 21:56 ..
-rw-r--r--@ 1 makeba staff 8196 Dec 3 21:58 .DS_Store
-rw-r--r-- 1 makeba staff 220 Oct 6 22:46 .editorconfig
-rw-r--r-- 1 makeba staff 793 Nov 27 15:46 .env
-rw-r--r-- 1 makeba staff 835 Nov 27 15:41 .env-prod
-rw-r--r-- 1 makeba staff 793 Nov 25 23:10 .env.example
-rw-r--r-- 1 makeba staff 251 Oct 27 05:23 .eslintrc.js
drwxr-xr-x 14 makeba staff 448 Dec 4 23:16 .git
-rw-r--r-- 1 makeba staff 111 Oct 6 22:46 .gitattributes
-rw-r--r-- 1 makeba staff 163 Oct 6 22:46 .gitignore
-rw-r--r-- 1 makeba staff 175 Nov 25 23:21 .htaccess
-rw-r--r-- 1 makeba staff 242 Oct 6 22:46 .styleci.yml
drwxr-xr-x 11 makeba staff 352 Nov 20 23:20 app
-rw-r--r-- 1 makeba staff 1686 Oct 6 22:46 artisan
drwxr-xr-x 4 makeba staff 128 Oct 6 22:46 bootstrap
-rw-r--r-- 1 makeba staff 1531 Oct 21 15:41 composer.json
-rw-r--r-- 1 makeba staff 177947 Oct 21 15:42 composer.lock
drwxr-xr-x 15 makeba staff 480 Nov 27 16:07 config
drwxr-xr-x 6 makeba staff 192 Oct 6 22:46 database
drwxr-xr-x 756 makeba staff 24192 Nov 12 15:55 node_modules
-rw-r--r-- 1 makeba staff 460304 Nov 12 15:55 package-lock.json
-rw-r--r-- 1 makeba staff 1365 Oct 27 05:22 package.json
-rw-r--r-- 1 makeba staff 1156 Oct 6 22:46 phpunit.xml
drwxrwxrwx 13 777 staff 416 Dec 3 21:56 public
drwxr-xr-x 7 makeba staff 224 Oct 10 18:12 resources
drwxr-xr-x 6 makeba staff 192 Oct 6 22:46 routes
-rw-r--r-- 1 makeba staff 563 Oct 6 22:46 server.php
drwxr-xr-x 5 makeba staff 160 Oct 6 22:46 storage
drwxr-xr-x 6 makeba staff 192 Oct 6 22:46 tests
drwxr-xr-x 42 makeba staff 1344 Oct 21 15:42 vendor
-rw-r--r-- 1 makeba staff 905 Nov 28 09:53 webpack.mix.js
You haven't changed it. Do you have zoom maybe?
Run chown -R makeba public.
and the images folder?
Your public folder is still owned by 777
Yeah, you've probably missed it when we mentioned it above. Good luck š
Please or to participate in this conversation.