I am trying to upload a photo from my Laravel 5 app to be stored in AWS. I am using the Postman REST client to test. When I upload a photo, the request returns an empty array. Does anyone know why this might be? Here's the code for my Avatar Controller:
class AvatarController extends Controller
{
public function __construct(AWS $aws)
{
$this->aws = $aws;
}
/**
* Store a new avatar for a user.
* POST northstar.com/users/{id}/avatar
*/
public function store(User $user, Request $request)
{
dd($request->all());
// dd($request->file('photo'));
$file = $request->file('photo');
// $file = Request::file('photo');
// $file = Input::file('photo');
$v = Validator::make(
$request->all(),
['photo' => 'required|image|mimes:jpeg,jpg|max:8000']
);
if($v->fails())
return Response::json(['error' => $v->errors()]);
$filename = $this->aws->storeImage('avatars', $file);
// Save filename to User model
$user->avatar = $filename;
$user->save();
// Respond to user with success
return response()->json('Photo uploaded!', 200);
}
}