Reputation: 788
I'm trying to send email with mailgun and send in body message url-to to upload files in user folder... the problem is that i do not know how to catch all files in directory and show if like links (to download it) .. here is what I tried to do with code:
$uploadsDir = 'https://lionbg.net/careers-test/upload'.$folderName.'/';
$first_char = mb_substr($jsonDecode["firstName"], 0, 1);
$directory = "upload/".$folderName."";
$filesInFolder = glob($directory . "/*.jpg");
$files = array();
foreach($filesInFolder as $filename){
//Simply print them out onto the screen.
//$files = "<a href='".$uploadsDir.$filename"' target='_blank'>".$filename.'</a>';
$result = array_merge($result, $filename);
}
$mg->sendMessage($domain, array(
'from' => '[email protected]',
'to' => '[email protected]',
'subject' => 'New applicant',
'text' => ''.$result.''
));
Upvotes: 0
Views: 71
Reputation: 2338
Not sure exactly what you are asking, but maybe. This is a trimmed down version. The HTML generated is just a list of the links to the files in the directory:
<?
$protocol = "http://" ;
define('DOMAIN', $protocol . $_SERVER['SERVER_NAME'] . '/' );
$directory = "upload";
array_map('files', glob($directory . "/*.jpg"));
function files($images) {
echo '<li><a href ="' . DOMAIN . $images . '" target="_blank">' . DOMAIN . $images . '</a></li>';
}
?>
Upvotes: 1