Upload images using a folder in php
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,
RekhaIt'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;
}
精彩评论