示例#1
0
 public function uploadPic()
 {
     if (Request::ajax() && Input::hasFile('profile_pic') && Input::file('profile_pic')->isValid()) {
         $file = Input::file('profile_pic');
         $path = $file->getRealPath();
         $destinationPath = public_path() . '/images';
         $filename = $file->getClientOriginalName();
         $filename = explode('.', $filename);
         $filename = date('mdHisy') . '.' . $filename[count($filename) - 1];
         $user = UserInfo::find(Auth::id());
         $old_filename = $user->profile_pic;
         if ($file->move($destinationPath, $filename)) {
             if ($old_filename != '' && $old_filename != null) {
                 $old_file = $destinationPath . '/' . $old_filename;
                 if (file_exists($old_file)) {
                     unlink($old_file);
                 }
             }
             $user->profile_pic = $filename;
             $user->save();
             return 'true';
         }
         return 'false';
     }
 }
示例#2
0
 private function userInfoList()
 {
     UserInfo::create(array('user_info_id' => 1, 'user_id' => 1, 'first_name' => 'Admin', 'middle_name' => 'D', 'last_name' => 'Admin'));
 }