这是我的控制器代码。
$fileArray=$request->multiple_file;
$data['name']="custom size mail";
$message='ok message';
Mail::send('emails.cutom_size_admin', $data, function($message) use ($fileArray)
{
$message->from('vvaug1295@gmail.com', 'Laravel');
$message->to('vikasarsha@gmail.com')->cc('vvaug1295@gmail.com');
for ($i=0; $i < count($fileArray); $i++) {
$message->attach($fileArray[$i]);
}
});
,我的CustomSizeMailToAdmin.php可邮寄代码是-
public function build()
{
$email= $this->from('haris@araaminc.com','Make My Foam')->subject('Contact Mail')->view('emails.cutom_size_admin')->with('data', $this->data);
foreach($attachments as $filePath){
$email->attach($filePath);
}
return $email;
}
我的表单html是-
<input type="file" multiple name="multiple_file[]" id="multiple_file">
答案 0 :(得分:0)
我做到了。
现在这是我的控制器代码-
$fileArray=$request->multiple_file;
for ($i=0; $i < count($fileArray); $i++) {
$fileext = $fileArray[$i]->getClientOriginalExtension();
$data['filepath'][$i]['fileimg'] = now()->format('dmyHis') .mt_rand(1000000, 9999999). '.' . $fileext;
$destinationPath = 'public/assets/images/customsize/';
$data['filepath'][$i]['filemove'] = $fileArray[$i]->move($destinationPath,
$data['filepath'][$i]['fileimg']);
}
if(isset($toEmail) && $toEmail!=''){
Mail::to('makemyfoam@gmail.com')->send(new CustomSizeMailToAdmin($data));
}
,我的CustomSizeMailToAdmin.php可邮寄代码是-
public function build()
{
$email= $this->from('haris@araaminc.com','Make My Foam')->subject('Contact Mail')->view('emails.cutom_size_admin')->with('data', $this->data);
foreach($this->data['filepath'] as $filePath){
$email->attach('https://makemyfoam.com/'.$filePath['filemove']);
}
return $email;
}