views:

30

answers:

2

Hi,

I have a folder with full of images.But I have to upload the images to mysql database.

How can I do it using php code?

Regards,
Rekha

A: 

It's usually not a good idea to do this. Read the discussion I linked to in the comment.

But to answer your question, here is what seems to be a pretty complete tutorial showing how to store images in a mySQL database.

Pekka
A: 

I am not store image in DB. It is a bad practice. If we have a some ID, we rename images as image$ID.ext. If we haven't ID, we write in DB only a filename. If you want to write in database all filenames of dir, try to use this code:

function getDirectoryList ($directory) {
   $results = array();
   $handler = opendir($directory);
   while ($file = readdir($handler)) {
      if ($file != "." && $file != "..") {
         $results[] = $file;
      }
   }
   closedir($handler);
   return $results;
}
Alexander.Plutov