亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用 dropzone laravel 通過電子郵件發送多張圖片

使用 dropzone laravel 通過電子郵件發送多張圖片

PHP
Smart貓小萌 2022-07-09 10:57:34
我想上傳多個圖像文件并通過電子郵件發送給客戶。但是 ajax 請求在添加到 dropzonecall to a member function getclientoriginalname() on array時會出現此錯誤。uploadMultiple: true,沒有該選項的多張圖片上傳。無論如何,我想通過電子郵件發送多個文件,我該怎么做?拖放區 js 代碼:Dropzone.options.uploadimg = {            paramName: "file", // The name that will be used to transfer the file            maxFilesize: 5, //MB            acceptedFiles: ".jpeg,.jpg,.png",            uploadMultiple: true,            addRemoveLinks: true,            success: function(file, response)             {                $.notify({                    message: 'Image uploaded Successfully!'                     },                    {                    type: 'success'                });            },            error: function(file, response)            {               return false;               console.log('fail to upload');            },            headers: {                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')            }        }SendMailController 發送上傳的圖片。    public function sendNotifications(Request $request)    {        $id_int = Cookie::get('jobid');        $img_name = Cookie::get('imgName');                $data = DB::table('customers')        ->join('jobs', 'jobs.id', '=', 'customers.id')        ->select('firstname','email')        ->where('jobs.id', '=', $id_int)        ->get()->toArray();        foreach ($data as $value) {            $customer_firstname = $value->firstname;            $customer_email = $value->email;        }        $pathToFile = public_path() . "\\uploads\\" . $img_name;        //send the email to the relevant customer email        Mail::to($customer_email)->send(new SendMail($customer_firstname, $pathToFile), function($message){                $message->attach($pathToFile);        });    }當我上傳多張圖片并通過電子郵件發送時,它只會在 dropzone 中發送最后上傳的文件。如何發送所有上傳的文件?
查看完整描述

1 回答

?
慕碼人2483693

TA貢獻1860條經驗 獲得超9個贊

因為它有多個文件,您需要遍歷文件變量來獲取文件


class ImageUploadController extends Controller

{

    public function uploadImage(Request $request){


        $img_files = $request->file('file');

        foreach($img_files as $img_file){

            $imgName = $img_file->getClientOriginalName();


            Cookie::queue(cookie('imgName', $imgName, $minute = 5));


            $img_file->move(public_path('uploads'), $imgName);

        }

    }

}


查看完整回答
反對 回復 2022-07-09
  • 1 回答
  • 0 關注
  • 149 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號