Storing a large number of images

后端 未结 12 799
没有蜡笔的小新
没有蜡笔的小新 2020-12-07 09:25

I\'m thinking about developing my own PHP based gallery for storing lots of pictures, maybe in the tens of thousands.

At the database I\'ll point to the url of the i

12条回答
  •  悲哀的现实
    2020-12-07 09:38

    I usually just use the numerical database id (auto_increment) and then use the modulu (%) operator to figure out where to put the file. Simple and scalable. For instance the path to image with id 12345 could be created like this:

    12345 % 100 = 45
    12345 % 1000 = 345
    

    Ends up in:

    /home/joe/images/345/45/12345.png
    

    Or something like that.

    If you're using Linux and ext3 and the filesystem, you must be aware that there are limits to the number of directories and files you can have in a directory. The limit is 32000 for dirs, so you should always strive to keep number of dirs low.

提交回复
热议问题