Neither one nor the other is best to store only the file name and leave your application to determine where to find this file. You can define it according to the database table. For example, let's say we have a user table in which there is an avatar field. You can save only the file name (foo.jpg) and then define the path in your application (c: \ xampp \ htdocs \ project1 \ img \ users \ foo.jpg). Or even better, you can leave this field and not store anything in the image, then you can check if the image with a user ID exists, for example 1.jpg, 2.jpg, etc.
But, if you really want to store absolute paths, start storing them from the project folder. For example, let's say you have c:\xampp\htdocs\my_project\module1 Then, start with /module1
If you need to save an external URL, you can save everything as http://www.foo.com/test
source share