我在一个目录中有500k图像.这些图像的名称存储在MySQL数据库中.我想将这500k图像分成10k每个目录.像img01中的10k图像,img02中的另外10k图像,等等.我怎么能用PHP程序做到这一点?有没有人可以帮我一个示例代码,所以我可以修改它?
提前致谢
我将展示一种伪代码方法,如果你仍然卡住了,你可以展示你尝试过的东西以及你被困在哪里.
Select all images
Loop through the result
if cntr mod 10k == 0 then
make new directory
else
use last directory
Move the file to the new directory.
end loop
Run Code Online (Sandbox Code Playgroud)
然后遍历每个目录,更新数据库中的位置.
现在,另一种方法是读取所有内容,然后根据内存可用性在循环中进行更新.