What are the potential pitfalls of storing images as BLOB files in a SQL database?

Storing images as BLOB files in a SQL database can lead to increased database size, slower performance, and potential issues with backups and maintenance. To address this, a common solution is to store the images as files on the server and store the file path in the database instead.

// Example code to store image file on server and save file path in database

// Upload image file to server
$targetDir = "uploads/";
$targetFile = $targetDir . basename($_FILES["fileToUpload"]["name"]);
move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $targetFile);

// Save file path in database
$imagePath = $targetFile;
$sql = "INSERT INTO images (image_path) VALUES ('$imagePath')";
mysqli_query($conn, $sql);