0
I’m not able to record several names of images separated by commas in a column of a row, I’m able to do multiple uploads, but each image name is recorded in a different row of the database. And I wanted it like this: the user uploads 5 photos and all the images inserted in the same column of the same row, each separated by comma in the database:
  --------------------------------------------------------------------------
  ID | img
  --------------------------------------------------------------------------
   1 | image(1).jpg, image(2).jpg, image(3).jpg, image(4).jpg, image(5).jpg
  --------------------------------------------------------------------------
Here is the Form:
<form action="public.php" method="post" enctype="multipart/form-data">
     <input type="file" name="images[]" accept="image/png, image/jpg, image/jpeg" multiple />
     <input type="submit" />
</form>
Follow the PHP code:
$fotoPost = $_FILES['images']; //recebe as imagens passadas pelo input file
$numFoto = count(array_filter($fotoPost['name'])); //conta quantas imagens foram inseridas no input
$folder = "../../arquivs/postagensImg/$dash/"; // pasta do arquivo
$extensao= array('image/jpeg', 'image/png'); // extensões permitidas
$maxSite = 1024 * 1024 * 5; // tamanho máximo da foto
$new_name = substr(sha1(time()).rand().md5(time()), - 40).".".$extensao; novo nome para imagem
for($i=0; $i < $numFoto; $i++){ //estrutura de repetição, só que isso vai adicionando várias linhas
    if(move_uploaded_file($tmp, $folder.$new_name)){
        $sqlInImg = mysqli_query($conn, "INSERT INTO postagem ( img, datePost) VALUES ('$new_name', NOW())");
            if($sqlInImg == true){
                $_SESSION['successPost'] = "Imagem postada com Sucesso";
                header("Location: ../direcao.php");
            }else{
                unlink("../../arquivs/postagensImg/$new_name");
                $_SESSION['errPost'] = "Desculpe, erro ao postar imagem";
                header("Location: ../direcao.php");
            }
        }else{
            $_SESSION['errPost'] = "Error ao adicionar imagem na pasta";
            header("Location: ../direcao.php");
        }
}
I will try to do here with implode(), if I get answer here as I did
I’m connected that it seems that can do what I intend with implode(), but someone could show me how more or less?
– Breno Castro
Put in the question the form part and php
– user60252
I already managed to do what I wanted, I will now put the answer I could find, it was easier than I thought, I researched in own kkkkkk curl
– Breno Castro