if(!empty($_FILES['attachfile']['name'][0])) {
$target_file = count($_FILES['attachfile']['name']);
for($i = 0; $i < $target_file; $i++) { // получаем количество файлов с массива
if($_FILES['attachfile']['error'][$i] == 0) { // нет ошибки при передаче файла - продолжаем!
$mail->AddAttachment($_FILES['attachfile']['tmp_name'][$i],
$_FILES['attachfile']['name'][$i],
'base64',
$_FILES['attachfile']['type'][$i]);
}
else {
$mail->ErrorInfo;
}
}
}
if(!$mail->send()) {
echo $resalt = 'Message could not be sent! ⛔';
}
else {
echo $resalt = '✅ <b>Message has been sent!</b> <br><br><pre><b><a href="https://mysite.com/adaptive.php" style="text-decoration:none;">⬅ Back to page</a></b></pre>';
}
if(!empty($_FILES['attachfile']['name'][0])) {
$target_file = count($_FILES['attachfile']['name']);
for($i = 0; $i < $target_file; $i++) {
if($_FILES['attachfile']['error'][$i] == 0) {
$mail->AddAttachment($_FILES['attachfile']['tmp_name'][$i],
$_FILES['attachfile']['name'][$i],
'base64',
$_FILES['attachfile']['type'][$i]);
}
else {
$mail->ErrorInfo;
}
}
}
[0] => /tmp/phpLopD4k
[1] => /tmp/phpgYOixX
)
[error] => Array
(
[0] => 0
[1] => 0
)
[size] => Array
(
[0] => 31031
[1] => 31031
)
)
)
Array
(
[attachfile] => Array
(
[name] => Array
(
[0] => 2020-08-05_22-59-18.png
[1] => 2020-08-05_22-59-18.png
)
[type] => Array
(
[0] => image/png
[1] => image/png
)
[tmp_name] => Array
(
[0] => /tmp/phpLopD4k
[1] => /tmp/phpgYOixX
)
[error] => Array
(
[0] => 0
[1] => 0
)
[size] => Array
(
[0] => 31031
[1] => 31031
)
)
)
[0] => Array
(
[0] => /tmp/phphLAynr
[1] => phphLAynr
[2] => 2020-08-05_22-59-18.png
[3] => base64
[4] => image/png
[5] =>
[6] => attachment
[7] => 2020-08-05_22-59-18.png
)
)
Array
(
[0] => Array
(
[0] => /tmp/phphLAynr
[1] => phphLAynr
[2] => 2020-08-05_22-59-18.png
[3] => base64
[4] => image/png
[5] =>
[6] => attachment
[7] => 2020-08-05_22-59-18.png
)
[1] => Array
(
[0] => /tmp/phpMuWRz4
[1] => phpMuWRz4
[2] => 2020-08-05_22-59-18.png
[3] => base64
[4] => image/png
[5] =>
[6] => attachment
[7] => 2020-08-05_22-59-18.png
)
)