I would personally use the full path as I might later on decide to split the images into variable paths. That would give me issues if I only had the filename and not the path.
Nov 1, 2019
1
Level 12
Save whole path to image for uploads?
Hi,
just wanted to ask if it is ok or best practise to save the whole path to database for uploads like avatars. I use Storage at laravel and get for example something like: user/4vR54Bnm/avatar/LJOGQJLe48GFceQxV5g4X5n8DZ1nguuZ7HQMzJj.png
The first part (user/4vR54Bnm/avatar/) is the path i want to use for the file and LJOGQJLe48GFceQxV5g4X5n8DZ1nguuZ7HQMzJj.png is the file.
Would you explode the full path and only store the file in database and create the full path again in your code? It is easier to store the whole path in db. But can i get problems with that later? What is best practise for that. I just ask before use it in my life project.
thx Norman
Level 102
2 likes
Please or to participate in this conversation.