How to add attachments without saving it in storage device ?

86 views
Skip to first unread message

Jago Kapok

unread,
Feb 8, 2017, 2:25:25 AM2/8/17
to Fat-Free Framework
I have a form to send email with attachment(s). But, I don't know how to send attachment(s) without saving it in storage device. ( I use f3 framework with phpMailer to send email )

I can do that with pure php like this :

...

$attachment_name
= $_FILES['attachment']['name'];
$attachment
= $_FILES['attachment']['tmp_name'];

$mail
->addAddress($to);
$mail
->addCC($cc);
$mail
->Subject = $subject;

foreach($attachment_name as $key){
    $file_name
= $attachment_name[$key];
    $tmp_file
= $attachment[$key];

    $mail
->addAttachment($tmp_file, $nama_file);
}
$mail
->send();


Now, how to do that with f3 framework ?

Sascha

unread,
Feb 8, 2017, 2:39:53 AM2/8/17
to Jago Kapok via Fat-Free Framework, Fat-Free Framework

What do you mean with "without saving it in storage"? Your example also saves the file in storage temporarily. it just doesn't move it form the temp directory before sending the mail.

You could simply keep using phpmailer even while using F3.


--
-- You've received this message because you are subscribed to the Google Groups group. To post to this group, send an email to f3-fra...@googlegroups.com. To unsubscribe from this group, send an email to f3-framework...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/f3-framework?hl=en
---
You received this message because you are subscribed to the Google Groups "Fat-Free Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to f3-framework...@googlegroups.com.
To post to this group, send email to f3-fra...@googlegroups.com.
Visit this group at https://groups.google.com/group/f3-framework.
To view this discussion on the web visit https://groups.google.com/d/msgid/f3-framework/8f62a6f5-3d5a-4e3d-86a0-254cdbb441f6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jago Kapok

unread,
Feb 8, 2017, 3:40:04 AM2/8/17
to Fat-Free Framework
Sorry if my question make you confused.

Yes, what I mean is "only save in temp directory and not to be moved".

I have try with this code ( in F3 ) to catch input with type = file :

$file = $this->f3->get('POST.attachments');
   $web
= \Web::instance();
   $files
= $web->receive(function($file,$formFieldName){
      var_dump
($file);
   
});

But I dont know how to take file name and temp file. Can you give me a solution ?

ikkez

unread,
Feb 8, 2017, 4:37:55 AM2/8/17
to Fat-Free Framework
$web->receive is used to validate uploaded files and move those temp files to your projects uploads folder. So if you want to save these files, just don't use web->receive at all.

Summer White

unread,
Feb 11, 2017, 7:15:09 AM2/11/17
to Fat-Free Framework
I did not know about $web->receive! Thank you Ikkez. *Goes rewrite all my uploading handling code*
Reply all
Reply to author
Forward
0 new messages