i need a script that saves a jpg in mysql table.i know that i need a table with a blob variable.what about the script????
saving images in mysql table
my advice is not to save it in the DB - it will make the DB huuuge if you have loads of images...
what I normally do is upload the image to a folder, then save the path to the image in the DB then when you need the image, just get the path to where u saved it!
for the script: google is your friend...!
I must agree with "mfacer". While it is technically possible to store images in databases, you will want to think long and hard about if you should store images in the database.
There are valid reasons to work the problem either way. You will want to consider at least the following issues:
how many images do you need to keep track of?
how large are the images?
how often are the images accessed/retreived?
does the web server and db server share memory?
what sort of caching is in front of the web server?
what do you need to backup? how often?
I used to never put images into databases. But memory is cheap now, and I've had a couple of instances where it made sense to store the images in the DB (small image set, rarely changed, infrequently retrieved).
ok , i must save the image's path in mysql table.but i cannot make it
could u make a simple script that saves the path of test.jpg that is stored in recourses folder????
Are you letting your users upload these images, or are you trying to catalog a pre-existing set of images? Both cases share some logic. You should probably familiarize yourself with the PHP file system functions (http://www.php.net/manual/en/ref.filesystem.php) and the directory functions (http://www.php.net/manual/en/ref.dir.php).
I went for an even simpler system of uploading images and finding paths.
I had one image per row in the database. When an image is uploaded it is renamed with the move command (to move from temp folder to /images) and given a name 1.jpg relates to record no 1 etc... infact I have 2 images because I dynamically create a thumbnail too so its in images/thumbs
No need to store paths in the database at all.
When I write php to show the files I know they are in /images or /images/thumbs/ and just build the file name from the record... works a treat!
C