on-internet
← Community

Only arrays and Traversables can be unpacked error with a guzzle HTTP POST request with multiple files

Stack Overflow ·

So I'm trying to do a POST request with guzzle with multiple files. The user has selected one or more files in a form and hit submit to POST the form. The following code gets run in the controller after that: public function upload(Request $request){ $validator = Validator::make($request->all(), [ 'file-upload' => 'required', 'file-upload.*' => 'file|mimes:mp3,wav,mp4' ]); if ($validator->fails()) { return redirect('/upload-files') ->withErrors($validator) ->withInput(); } $names = []; if($request->hasFile('file-upload')) { foreach ($request->file('file-upload') as $file) { if(file_exists($fil

Comments

Sign in or sign up to comment and upvote.

No comments yet.