Too many pictures in a folder.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
PanK
Forum Commoner
Posts: 36
Joined: Mon Nov 22, 2004 1:24 pm
Location: Richmond Hill, ON, Canada

Too many pictures in a folder.

Post by PanK »

I have a website running on Apache. There is a limit on the files in folder - 32000. i have 29000 so far. What is the best way to deal with it?
And does anybody know how to manage BLOB?
Thank you.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

Use a database.... just create a blob field and then when inserting a file go:

$data=file_get_contents($tmpfile);
$data=strip_slashes($data);
INSERT INTO `files` (`data`) VALUES ('$data')


Get it?
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

You could either put them into a database or simply split the images into more folders - it sounds like you add a lot of photos on a regular basis, so why not have a new folder for each month or week.
PanK
Forum Commoner
Posts: 36
Joined: Mon Nov 22, 2004 1:24 pm
Location: Richmond Hill, ON, Canada

Post by PanK »

Thanx, I've decided to store pictures in Data Base using BLOB. Thought about different folders. Not going to work.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

My philosophy:

Anytime you have more then 50 things to store use a database rather then useing any type of files or anything, just because databases are easier to manage and search for things.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

Just a note: In my experience, storing images in a database, while handy, will increase the time it takes for a client to fully download the image. It takes longer to pull the data out of the db and send it to the browser, than it does to just send the file location to the browser. I'm not saying using a DB is a bad idea, in fact it sounds like the best possible idea, but just a warning that page load times will increase.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply