|
Posted by Peter Chant on 03/27/07 00:40
Nosferatum wrote:
> Ok, I have been told that it's not a good idea to store binary files
> (like pdfs etc.) in MySQL, but in the file system. I am in desperat
> need of a system where I can upload binary files like this, categorize
> them, add some extra info to each file, and list them/make them
> downloadable. (listing and making files downloadable is easy with
> PHP).
> If I upload each file to a folder in the web server file system, how
> is it then that I can refer extra information like a category and some
> metadata to the files that I later will list? No database=no extra
> info?
> I need a human understandable answere, since I am a really newbie in
> PHP and MySQL. Hopefully a code example. If someone could help.
I'm certainly not the best coder here by miles but my suggestion is that
you create a table to store the information about the files and a filename
including path. You save the file to that path and use a SQL query to
extract the path name when you want to access the file. Up to you what you
use for file names. In my own photo database I am writing I use an auto
incrementing primary key as the file path for example, so the thumbnail for
photo_id=123456 lives at /data_dir/1/2/3/4/5/small.jpg. Someone will have
a better idea than this, but this one seems to work for low usage.
--
http://www.petezilla.co.uk
Navigation:
[Reply to this message]
|