sigil88
3/31/2017 - 9:38 AM

joomla rsforms pro - php to attach multiple files based on a checkbox input value

joomla rsforms pro - php to attach multiple files based on a checkbox input value

$brochure = $_POST['form']['brochure'];

// PDF options
$concretePDF = JPATH_SITE.'/images/Resources/Brochures/concrete-brochure.pdf'; 
$timberPDF = JPATH_SITE.'/images/Resources/Brochures/timber-brochure.pdf'; 
$steelPDF = JPATH_SITE.'/images/Resources/Brochures/steel-brochure.pdf'; 
$helicalPDF = JPATH_SITE.'/images/Resources/Brochures/helical-brochure.pdf'; 
$wachenfeldPDF = JPATH_SITE.'/images/Resources/Brochures/wachenfeld-brochure.pdf'; 


// check for which brochures were chosen in 'brochure' field
if (in_array("Concrete Brochure", $brochure, true)) {
  array_push($userEmail['files'], $concretePDF);
}

if (in_array("Timber Brochure", $brochure, true)) {
   array_push($userEmail['files'], $timberPDF);
}

if (in_array("Steel Brochure", $brochure, true)) {
   array_push($userEmail['files'], $steelPDF);
}

if (in_array("Helical Brochure", $brochure, true)) {
   array_push($userEmail['files'], $helicalPDF);
}

if (in_array("Wachenfeld Brochure", $brochure, true)) {
   array_push($userEmail['files'], $wachenfeldPDF);
}

//die(var_dump($userEmail));