目前我仅使用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,它工作正常
[目前,我使用Laravel Passport API上传了一张图片,我有此代码,并且可以正常工作。 //将文件保存到公用文件夹$ dateTime = date('Ymd_His'); $ file = $ ...
是的,可以使用您的代码完成此操作