public function EditSelectedNews($id) { $title = $_POST["newsTitle"]; $text = $_POST["newsText"]; $author = $_POST["newsAuthor"]; if (Input::hasFile("news_picture")) { $file = Input::file("news_picture"); $folder = '/images/'; $destinationPath = public_path() . $folder; $filename = str_random(6) . '_' . $file->getClientOriginalName(); $img_path = $folder . $filename; $uploadSuccess = $file->move($destinationPath, $filename); $pd = News::GetSingleNews($id); $img = $pd[0]->news_image; if (File::exists(public_path() . $img)) { File::delete(public_path() . $img); } } else { $n = News::GetSingleNews($id); $img_path = $n[0]->news_image; } News::UpdateNews($title, $text, $img_path, $author, $id); return Redirect::back(); }