I am using the below script to validate and send attachment with swiftmailer.

PHP Code:
<?php 

session_start
();

/* check_input code to validate some field */

/*  some regex to validate email, text only, etc */


if (!empty($_FILES["photo"])) {

  foreach (
$_FILES["photo"]["tmp_name"] as $key => $value) {

if (!
$_FILES["photo"]["error"][$key]) {

  
$message->attach(Swift_Attachment::newInstance(($value),     $_FILES["photo"]["name"][$key], $_FILES["photo"]["type"][$key]))
  ->
attach(Swift_Attachment::newInstance(($value), $_FILES["photo"]["name"][$key], $_FILES["photo"]["type"][$key]))
  ->
attach(Swift_Attachment::newInstance(($value), $_FILES["photo"]["name"][$key], $_FILES["photo"]["type"][$key]))
  ->
attach(Swift_Attachment::newInstance(($value), $_FILES["photo"]["name"][$key], $_FILES["photo"]["type"][$key]));

}  }}
require_once 
'../lib/swift_required.php'

$transport Swift_MailTransport::newInstance(); 

$mailer Swift_Mailer::newInstance($transport); 

$message Swift_Message::newInstance() 
->
setSubject(array('Submitted Photo')) 
->
setFrom(array($email => $name)) 
->
setTo(array('receiver@domain.org' => 'A name')) 
->
setBody($html'text/html'

$result $mailer->send($message);

function 
check_input($data$problem='')
{
$data trim($data);
$data stripslashes($data);
$data htmlspecialchars($data);
if (
$problem && strlen($data) == 0)
{
    
show_error($problem);
}
return 
$data;
}

function 
show_error($Error)
{}
?>
I am getting the below message. Please help.

Warning: preg_split() expects parameter 2 to be string, array given in lib/classes/Swift/Mime/Headers/AbstractHeader.php on line 340

Warning: Invalid argument supplied for foreach() in lib/classes/Swift/Mime/Headers/AbstractHeader.php on line 340