Hi,
This is partially mysql-related so forgive me if I'm in the wrong thread.
I created a site for bands which allows them to upload a picture. The script will then name the image based on their unique band_id + the image extension. In other words; if band #13327 signs in and uploads mypic.jpg; it is renamed to 13327.jpg and put in the band_pics folder. It will then enter 13327.jpg into the IMAGE column of the BAND_INFO table.
As you can see; in my newbiness I designed it to send every image to the same folder. I now have a directory pushing 15k files and my ftp program just giggles when I try to view them.
I've decided on trying to reduce it to a max of 100 images per folders by coding so that bands with band_id's <=100 would have their pic stored in a folder called bandpics/p100.
Bands w/ id's >100 & <=200 go into bandpics/p200.
..and could use some help on code to move them and update the database.
(something like🙂
SELECT band_id, band_image FROM band_page...
while...
if(band_id <=100){
//find that entry's band_pic and move it from /bandpics to bandpics/p100
//rename the pic in mysql from 24.jpg to /p100/24.jpg
if(band_id >100 & band_id <=200){
//find that entry's band_pic and move it from /bandpics to bandpics/p200
//rename the pic in mysql from 143.jpg to /p200/143.jpg
//...
I will then need it to do so on the fly for new bands. To save on fanciness should I go ahead and create plenty of folders ahead of time and not have to worry about creating them on the fly when new members break a 100-mark?
If I can extract the bandid as being 14455; how would I tell it to use the p15000 folder?
..and by the way,..am I going about this completely wrong? I'm open for any suggestions.
Thanks kindly for your time.