开发者

Upload images using a folder in php

开发者 https://www.devze.com 2023-01-15 20:59 出处:网络
I have a folder with full of images.But I have to up开发者_JS百科load the images to mysql database.

I have a folder with full of images.But I have to up开发者_JS百科load the images to mysql database.

How can I do it using php code?

Regards,

Rekha


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.


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;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消