Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It really depends on the amount and size of the images if you are planning to store them into the database. I have written eCommerce systems that serve thousands of images from a MySQL database of various sizes without issue except for load on the system.</p> <p>The down side to storing the images in the database is that every image would require a PHP script to execute to serve it out, increasing the load on both the database server and the web server.</p> <p>I would recommend that you use a hash to name the file, like md5, or sha1, and prepend the user_id to it, storing the hash into the database.</p> <pre><code>$filename = md5_file($filename) . $extension; </code></pre> <p>For versions I would have a table in the database that contained four columns + any extra metadata you wish to store.</p> <p>Example:</p> <pre><code>image_id | parent_image_id | user_id | hash ------------------------------------------------------- 1 | NULL | 1 | AAAAAAAAAAAAAAAA 2 | 1 | 1 | BBBBBBBBBBBBBBBB 3 | 2 | 1 | CCCCCCCCCCCCCCCC </code></pre> <p>Then you can have multiple sub-versions if you so desire, branching out from any version.</p> <p>For the file system, for performance you should store the files in a bucket structure... if you use the hash method you could do the following...</p> <p>Say the filename is "aabbccddeeff.jpg", you would store the file into folders like so:</p> <p>images/aa/bb/cc/dd/eeff.jpg</p> <p>This is especially important if you are going to have thousands of image files.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload