@@ 684-703 (lines=20) @@ | ||
681 | } |
|
682 | ||
683 | // is new image uploaded? |
|
684 | if ($file = Input::file('pic')) |
|
685 | { |
|
686 | $fileName = $file->getClientOriginalName(); |
|
687 | $extension = $file->getClientOriginalExtension() ?: 'png'; |
|
688 | ||
689 | if ($extension == 'png' || $extension == 'PNG' || $extension == 'JGP' || $extension == 'jpg' || $extension == 'gif') |
|
690 | { |
|
691 | $folderName = '/uploads/users/'; |
|
692 | $destinationPath = public_path() . $folderName; |
|
693 | $safeName = str_random(10).'.'.$extension; |
|
694 | $file->move($destinationPath, $safeName); |
|
695 | ||
696 | //delete old pic if exists |
|
697 | if(File::exists(public_path() . $folderName . $user->pic)) |
|
698 | File::delete(public_path() . $folderName . $user->pic); |
|
699 | ||
700 | //save new file path into db |
|
701 | $user->pic = $safeName; |
|
702 | } |
|
703 | } |
|
704 | ||
705 | /* |
|
706 | // Get the current user groups |
|
@@ 859-878 (lines=20) @@ | ||
856 | $user->force_new_password = 0; |
|
857 | ||
858 | // is new image uploaded? |
|
859 | if ($file = Input::file('pic')) |
|
860 | { |
|
861 | $fileName = $file->getClientOriginalName(); |
|
862 | $extension = $file->getClientOriginalExtension() ?: 'png'; |
|
863 | ||
864 | if ($extension == 'png' || $extension == 'PNG' || $extension == 'JGP' || $extension == 'jpg' || $extension == 'gif') |
|
865 | { |
|
866 | $folderName = '/uploads/users/'; |
|
867 | $destinationPath = public_path() . $folderName; |
|
868 | $safeName = str_random(10).'.'.$extension; |
|
869 | $file->move($destinationPath, $safeName); |
|
870 | ||
871 | //delete old pic if exists |
|
872 | if(File::exists(public_path() . $folderName . $user->pic)) |
|
873 | File::delete(public_path() . $folderName . $user->pic); |
|
874 | ||
875 | //save new file path into db |
|
876 | $user->pic = $safeName; |
|
877 | } |
|
878 | } |
|
879 | ||
880 | $user->save(); |
|
881 |