This is my jQuery code:
$.post('../myprofile/storeitem',
{
name: $("#name").val(),
price: $("#price").val(),
description: $("#description").val(),
city: $("#city").val(),
telephone: $("#telephone").val(),
address: $("#address").val(),
picture: $("#picture").val()
},
In my controller I have:
$validation = Validator::make(Input::all(), Product::$rules);
if($validation->fails()) {
return Response::json(['success' => false, 'error' => $validation->errors()->toArray()]);
}
else {
$image = Input::file('picture');
$filename = $image->getClientOriginalName();
My rule for validating the picture field which is located in the Products model among other rules:
'picture' => 'required|image|mimes:jpg,jpeg,bmp,png|max:2000'
After a partial successful validation i get the error:
{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Call to a member function getClientOriginalExtension() on a non-object","file":"C:\\wamp\\www\\pro\\app\\controllers\\MyprofileController.php","line":125}}