What I do is store the images in a temporary folder within the root directory while you need them and save the location of the file to the database instead of the file itself. So using knows example above I would put "/images/products/1912.jpg" in the database as a reference to which image is being used.