-3

I wanna store multiple images into database with single column show i was designed code but my code is not working properly actually image uploading successfully and also store database record in single column but not uploading local directory folder i want this image upload in database and also upload local directory folder

Note: i don't want to store file type, size, etc.. i want only image

i have two field in database 1st one is id another is image

here is the my php code

    $R_Prop_Images =$_FILES["R_Prop_Images"]["name"]; 
    
    $location="../property_images/";
    $R_Prop_Images =implode(", ",$R_Prop_Images);
    if(!empty($R_Prop_Images)){
    foreach ($R_Prop_Images as $key => $val) {
        $targetPath=$location .$val;
        move_uploaded_file($_FILES["R_Prop_Images"]["tmp_name"][$key], $targetPath);
    }
}

here is the my html code

<span class="btn_upload">
<input type="file" id="imag" title="" name='R_Prop_Images[]' class="input-img" multiple />
<span>UPLOAD FILES</span>
ADyson
  • 57,178
  • 14
  • 51
  • 63
A KHAN
  • 1
  • 2
    This question looks very similar to [this one](https://stackoverflow.com/questions/76934050/problem-uploading-multiple-images-in-database-with-single-column), but was asked by a different person. What is going on? – KIKO Software Aug 19 '23 at 09:23
  • yeah its similar but problem is different and also code is different please you have any idea about that give me answer – A KHAN Aug 19 '23 at 09:38
  • 1
    Your code makes little sense. I even think you might have mixed up `implode()` and `explode()`? – KIKO Software Aug 19 '23 at 09:42
  • `i wanna store multiple images into database with single column`...in that case your database design is fundamentally wrong. Please read https://stackoverflow.com/questions/3653462/is-storing-a-delimited-list-in-a-database-column-really-that-bad and normalise your schema properly before proceeding. You will be thankful in the long term if you do this. – ADyson Aug 19 '23 at 09:45
  • 3
    P.s. Duplicate of [Problem uploading multiple images in database with single column](https://stackoverflow.com/questions/76934050/problem-uploading-multiple-images-in-database-with-single-column). Dont post the same thing twice please, it just dilutes the efforts of people to help, and in the end wastes everyone's time, including yours. If you have an update, edit the original post. – ADyson Aug 19 '23 at 09:47
  • but my code is working now but little bit issue is that not uploading image by directory you have any idea about that. if you have an idea about this problem so please can you generate the right code for me? – A KHAN Aug 19 '23 at 09:48
  • Sounds like a different issue now. That _is_ something you can post a new question about. Delete this and try again – ADyson Aug 19 '23 at 09:49
  • 1
    We are here to help you solve coding problems, not to write the full correct for you. This [guide to PHP debugging](https://stackify.com/php-debugging-guide/) could get you started. – KIKO Software Aug 19 '23 at 10:01
  • [`IMPLODE()`](https://www.php.net/manual/en/function.implode.php) Is not what you want to do if you want to loop over an array – RiggsFolly Aug 19 '23 at 10:01
  • `imploding` the array contents gave you string value, but you can not `foreach` over a string. `if(!empty($R_Prop_Images)){` - the only way this _could_ be empty, is if the original array contained only a single item, that had a value that would result in an empty string in a string context. Not sure what you wanted to achieve by that weirdly written "check", but if you only wanted to make sure that no processing is done, if the array was empty - then you did not have to explicitly implement _anything_, because a `foreach` loop over an empty array would not _do_ anything in the first place. – CBroe Aug 22 '23 at 10:43

0 Answers0