PHP: Storing picture in the file directory, image name in db and retrieving an image
<p>After doing research, I found that it is more recommended to save the image name in database and the actual image in a file directory. Two of the  few reasons is that it is more safer and the pictures load a lot quicker. But I don't really get the point of doing this procedure because every time I retrieve the pictures with the firebug tool i can find out the picture path in the file directory which can lead to potential breach. </p>

<p>Am I doing this correctly or it is not suppose to show the complete file directory path of the image?</p>

<p>PHP for saving image into database</p>

<pre><code>$images = retrieve_images();
    insert_images_into_database($images);

    function retrieve_images()
    {        
        $images = explode(',', $_GET['i']);

        return $images;
    }

    function insert_images_into_database($images)
    {
        if(!$images) //There were no images to return
            return false;        

       $pdo = get_database_connection();

        foreach($images as $image)
        {

            $path = Configuration::getUploadUrlPath('medium', 'target');
            $sql = "INSERT INTO `urlImage` (`image_name`) VALUES ( ? )";

            $prepared = $pdo-&gt;prepare($sql);
            $prepared-&gt;execute(array($image));
            echo ('&lt;div&gt;&lt;img src="'. $path . $image . '" /&gt;&lt;/div&gt;');
        }
    }
</code></pre>
