Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Wygekas's avatar

Unable to save files in production server

Hi, im trying to save user inserted images to my storage but it is not working.

File upload snippet:

$file->storeAs("/public/all_users/".Auth::id()."/", "profile_image.".$file->getClientOriginalExtension());

I also tried another way to save files:

Storage::put("public/storage/all_users/".Auth::id()."/profile_image.".$file->getClientOriginalExtension() , $file);

I also use database to get path to image and display, it is working as intended. Laravel is unable to write to my all_users folder (using filezila i confirmed that)

  • I don't get any errors
  • Website is hosted on DigitalOcean droplet ubuntu 20.04
  • My absolute path to all_users folder: /var/www/MYPROJECT/public/storage/all_users/user_id/ image.jpg
0 likes
1 reply
Wygekas's avatar
Wygekas
OP
Best Answer
Level 1

SOLVED: Problem was two copies of storage. When deploying project, GIT doesn't provide symlink to storage from public folder, that shortcut he made into folder itself. When deploying you must recreate symlink.

  • It is bad practice to upload storage with GIT to GITHUB

Please or to participate in this conversation.