Jump to content

Front Module allow user to upload file and send it in attachment


vinaysaini

Recommended Posts

Hi,

 

I am creating a module where user can upload a file. And then I need to send that attachment file to shop owner.

 

And the code I am using is below.

	$url = $_FILES['fileupload']['tmp_name'];
	$mime = mime_content_type($_FILES['fileupload']['tmp_name']);
	$file_attachment = array('content' => $url, 'name' => $_FILES['fileupload']['name'], 'mime' => $mime);

	Mail::Send(
        $this->context->language->id,
        'customer_attachment',
        Mail::l('test email.', $this->context->language->id),
        $template_vars, // Template Vars 
        "[email protected]",
        "name",
        NULL,
        "name",                    
        $file_attachment,
        NULL,
        //dirname(__FILE__).'/mails/'
        dirname(__FILE__).'/../../mails/' //template_path        
    );

I am getting the file in email attachment with the name. But the files seems to be corrupted. By the time files reaches to email it's size becomes 1KB and it does not open.

Edited by vinaysaini (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...