public function addtopimg() { $input_value = array('title' => Input::get('title'), 'text' => Input::get('text'), 'img_url' => Input::file('image')); $input_check = array('title' => array('required'), 'text' => array('required'), 'img_url' => array('required', 'mimes:png,gif,jpeg,jpg')); $validation = Validator::make($input_value, $input_check); if ($validation->fails()) { $error = $validation->messages()->toArray(); return View::make('admin.top.top')->with('add', 'add')->with('error_add', $error); } else { $type = Input::file('image')->getClientOriginalExtension(); $imgName = rand(1111111, 9999999) . time() . "." . $type; $path = 'uploadtop'; $upload = Input::file('image')->move($path, $imgName); if ($upload) { $top = new Top(); $top->img_url = $imgName; $top->title = Input::get('title'); $top->text = Input::get('text'); $top->save(); return Redirect::to('addslidertop')->with('update_img', 'save'); } } }