Hi
I have about 4 gigs worth of pictures. I would like to store these in a mysql table to use on my website.
I know you can store images in a mysql table as a BLOB. I have the following questions:
1. How do I fetch a list of files on my server in a specific folder and loop them them?
2. can I remove them once inserted into mysql table?
Any help much appreciated and I am still a php newbie so please excuse some of my silly questions.
Upload files for a specific folder and store them in mysql
Moderator: General Moderators
-
funkyapache
- Forum Newbie
- Posts: 11
- Joined: Tue Mar 24, 2009 11:19 am
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
Re: Upload files for a specific folder and store them in mysql
scandir() if you're on PHP5; glob() also works well.How do I fetch a list of files on my server in a specific folder and loop them them?
unlink(). I'd be careful about doing that until you're sure you know how to get the images back out of MySQL.can I remove them once inserted into mysql table?
Why do you want to store images in the database? Most modern web applications keep them in the filesystem for performance reasons.
-
funkyapache
- Forum Newbie
- Posts: 11
- Joined: Tue Mar 24, 2009 11:19 am
Re: Upload files for a specific folder and store them in mysql
Hi Ambush,
Thanks for the reply, I'll do some reading up on those two functions.
I was hoping to make my website self contained and was hoping to just backup the db rather than the db and the system files. I thought it would be difficult to link all my pictures in different directorys but your suggestion did get me thinking and I surpose I could create a php function that would create a list of files and directories and loop through them and for each picture insert a reference (i.e the files path in the filesystem) into the table and then just pull out the href/path from the table and place it onto the page in a img tag.
I'll let you know how I get on.
Thanks for the reply, I'll do some reading up on those two functions.
I was hoping to make my website self contained and was hoping to just backup the db rather than the db and the system files. I thought it would be difficult to link all my pictures in different directorys but your suggestion did get me thinking and I surpose I could create a php function that would create a list of files and directories and loop through them and for each picture insert a reference (i.e the files path in the filesystem) into the table and then just pull out the href/path from the table and place it onto the page in a img tag.
I'll let you know how I get on.