How should file paths to images be stored in a database to ensure proper display in a web browser?

File paths to images should be stored in a database as relative paths, rather than absolute paths, to ensure proper display in a web browser. This allows the images to be displayed correctly regardless of the server's file structure or domain name changes. By using relative paths, the images can be easily referenced and displayed within the web application.

// Assuming $imagePath contains the relative path to the image file
$imagePath = "images/example.jpg";

// Display the image using the relative path
echo "<img src='$imagePath' alt='Example Image'>";