Fetch
Fetch copied to clipboard
getAttachments() save the file with 0 bytes size
I'm using this Class since two years ago. I want now save the attachments from the incoming email but it saves just the filename with cero data.
` $attachments = $message->getAttachments();
if ($attachments !== false) { foreach ($attachments as $attachment) {
var_dump($attachment);
$path = APPPATH . 'cache/uploads/' . $user->id;
if (!is_dir(APPPATH . 'cache/uploads/' . $user->id)) mkdir(APPPATH . 'cache/uploads/' . $user->id);
$name = $attachment->getFileName();
var_dump($name);
$data = $attachment->getData();
var_dump($data);
$mime = $attachment->getMimeType();
$size = $attachment->getSize();
$saved = $attachment->saveToDirectory($path);
//file_put_contents($path . "/asd.asd", $data);
$this->attach = true;
}
}`