0
I’m trying to retrieve attachment names in a single variable and then print them all together. Note that I already send each file to the upload folder. So this is not the case. I really just want to rescue the names of these attachments, nothing else. How to do this? These attachments come from an imput file Multiple then in a loop send all the files to the upload folder successfully. But I want to take advantage of the loop to rescue the name.
<?php
$arquivo = isset($_FILES['foto']) ? $_FILES['foto'] : FALSE;
for ($k = 0; $k < count($arquivo['name']); $k++){
$destino = $diretorio."/" . date("d.m.Y-H.i.s"). $arquivo['name'][$k];
$acumulaNome = ; // Como ficaria esta variavel que acumula os nomes apenas?
if (move_uploaded_file($arquivo['tmp_name'][$k], $destino)) {echo "Sucesso"; }
else {echo "erro";}
}
?>
$acumulaNome .= $arquivo['name'][$k] ."\r\n";
- The"\r\n"
is the line break, can exchange for"<br>"
or"<br>\n"
if it is displayed on a web page. Depending on the application, you can use only"\n"
that already solves. Probably theimplode
be the most suitable way, as stated by Omine.– Bacco
I was until now trying to solve my problem starting with this variable $acumulaNome and I saw your comment. Simply the best answer is fully functional, I did the tests and already list the names, I change the name (thing q could not in the other answers) I receive the email with the list of all names, just send the variable. Fabulous. Thank you very much, if you want to ask the question mark street answer
– GOLX
Golx can leave as it is, @Danielomine’s reply is good. The
implode(', ', $arquivo['name']);
would anyway, only you change the ',' for what I commented above."\r"
, or even"<br>\r"
. Example: AFTER THE LOOP, not inside, you put it like this:$acumulanome = implode( "<br>\n", $arquivo['name'] );
– Bacco
Okay. Thank you, if I asked a good question, please mark
– GOLX