0

laravel returns 403 forbidded when trying to access a file I uploaded to a new directory that was created while uploading the file

Please help what can I do?

Paulos Ab
  • 319
  • 4
  • 16
  • Depends where the directory was that you created.... – Snapey Aug 06 '22 at 22:07
  • @Snapey thanks for your response, i linked the directory to a directory that is outside of the laravel app – Paulos Ab Aug 07 '22 at 18:14
  • Your web server can only serve images that are within the public area of the site (the document root and all the folders below it). It cannot serve images from a folder elsewhere – Snapey Aug 07 '22 at 20:54
  • I still don't understand that, it only worked after I changed ran laravel permission commands - to give permission to laravel's storage and bootstrap folder - but it gave me concern that, I'm I going to be running that same command everytime a user creates a directory for the user to be able to access the files in the directory – Paulos Ab Aug 08 '22 at 23:38
  • These should not be accessible. Presumably you have `public' visible in your URLs which indicates a security issue – Snapey Aug 09 '22 at 08:57
  • okay, please could you propose a solution for it? – Paulos Ab Aug 09 '22 at 20:30
  • Serve the public folder as the _document root_ and store the images in some folder off public – Snapey Aug 09 '22 at 21:26
  • Okay thanks, I'll try that, please how do I serve the public folder as the document root? – Paulos Ab Aug 10 '22 at 20:33
  • Depends on your web server (nginx or Apache usually) Plenty to google, eg `set nginx document root` – Snapey Aug 10 '22 at 21:59
  • okay, thanks, I will google it and try it – Paulos Ab Aug 12 '22 at 17:32

0 Answers0