Laravel Passport API上传多张图片

问题描述 投票:1回答:1

目前我仅使用Laravel Passport API上传了一张图片>

我有此代码,它工作正常。

        //Saves file to public folder
        $dateTime = date('Ymd_His');
        $file = $request->file('file');
        $fileName = $dateTime . '-' . $file->getClientOriginalName();
        $savePath = public_path('/upload/img/');
        $file->move($savePath, $fileName);

        //This saves the current file path of image to mytable
        $ActivityLog = new ActivityLogImg;
        $ActivityLog->actCode = $activity_code;
        $ActivityLog->projCode = $request->projCode;
        $ActivityLog->attachment = "/upload/img/".$fileName;
        $ActivityLog->type = "IMAGE";
        $ActivityLog->deleted = 0;
        $ActivityLog->created_by_id = Auth::user()->company_id;
        $ActivityLog->created_by_name = Auth::user()->name;
        $ActivityLog->created_at = now();
        $ActivityLog->updated_at = now();
        $ActivityLog->save();

        return response([
            "status"=>"ok",
            "message"=>"Activity successfully submitted!"
        ]);

并且我有这个邮递员的请求来测试api,它工作正常

enter image description here

enter image description here现在,我正在尝试在一个请求中多次上传图片。此代码可能吗?

[目前,我使用Laravel Passport API上传了一张图片,我有此代码,并且可以正常工作。 //将文件保存到公用文件夹$ dateTime = date('Ymd_His'); $ file = $ ...

php laravel postman laravel-passport
1个回答
1
投票

是的,可以使用您的代码完成此操作

© www.soinside.com 2019 - 2024. All rights reserved.