ok.. i don't know how many of you had this problem in Laravel.. i could not find any solution for this.
i'm validating the uploaded image using Validator by setting rules with mime type jpeg, bmp and png. I flash an error message if it's not of these types.
It works fine for all file types, but when i upload an mp3 or mp4 it shows an exception in my controller.
MyImageController.php Code :
public function addImageDetails()
{
$input = Request::all();
$ID = $input['ID'];
$name = $input['name'];
$file = array('image' => Input::file('image'));
$rules = array('image' => 'required|mimes:jpeg,jpg,bmp,png');
$validator = Validator::make($file, $rules);
if ($validator->fails()) {
\Session::flash('flash_message_error','Should be an Image');
return view('addDetails');
}
else {
//If its image im saving the ID, name and the image in my DB
}
This is the error that i get when i upload an mp3 or mp4
ErrorException in MyImageController.php line 25:
Undefined index: ID
validating all other file types like [.txt, .doc, .ppt, .exe, .torrent] etc..
$input['id']
? – Sulthan Allaudeen