1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-08 07:47:00 +02:00

Allow for alternative names to be supplied

This commit is contained in:
Benjamin Milde
2016-10-01 20:35:09 +02:00
parent ea6f60246d
commit 2fe4ff02f2
2 changed files with 6 additions and 5 deletions

View File

@@ -328,11 +328,12 @@ class WireMail extends WireData implements WireMailInterface {
* @return this
*
*/
public function attachment($value) {
public function attachment($value, $filename = '') {
if(is_null($value)) {
$this->mail['attachments'] = array();
} else if(is_file($value)) {
$this->mail['attachments'][] = $value;
$filename = $filename ?: basename($value);
$this->mail['attachments'][$filename] = $value;
}
return $this;
}
@@ -389,10 +390,9 @@ class WireMail extends WireData implements WireMailInterface {
}
// Attachments
foreach ($this->attachments as $file) {
foreach ($this->attachments as $filename => $file) {
$content = file_get_contents($file);
$content = chunk_split(base64_encode($content));
$filename = basename($file);
$body .= "--$boundary\r\n" .
"Content-Type: application/octet-stream; name=\"$filename\"\r\n" .

View File

@@ -94,9 +94,10 @@ interface WireMailInterface {
*
*
* @param string $value
* @param string $filename
* @return this
*
public function attachment($value);
public function attachment($value, $filename = '');
*/
/**