function save($id = NULL) { if ($_POST) { $camp = new Camp($id); $camp->from_array($_POST); if ($_FILES['map']['name']) { if ($id) { $camp->delete_file('uploads/camp', 'map'); } $camp->map = $camp->upload($_FILES['map'], 'uploads/camp'); } $camp->save(); set_notify('success', lang('save_data_complete')); } redirect('camps'); }