This is my excel file in public folder. Heres the directory structure
The file name is user_products.xlsx. I need to send it as an attachment. Here is the mail class's build function
public function build()
{
// dd($this->data);
return $this->subject('Subject:User Cart Inquiry')->view('emails.sendUserSubmitMail')
->attach(public_path('user_products.xlsx'), [
'as' => 'user products.xlsx',
'mime' => 'application/xlsx',
])
->with('data', $this->data);
}
The mail is working fine, but when i added the ->attach()
, its showing error. The error is
message: "Unable to open file for reading [/opt/lampp/htdocs/RC/public/user_products.xlsx]"
Please help. Thank You!
Never give 777 permission on production. Try this.
# sudo adduser $USER www-data
# sudo chown $USER:www-data -R /opt/lampp/htdocs
# sudo chmod 755 -R /opt/lampp/htdocs
And now change the details in apache.
# sudo nano /opt/lampp/etc/httpd.conf
to this
User username
Group www-data
Change username with your currently logged in user, to see that execute this:
# whoami
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.