Preview dan Delete Profile Picture
This commit is contained in:
parent
326bbfd7ac
commit
97c9669a82
|
@ -7,6 +7,7 @@
|
|||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class UserController extends Controller
|
||||
|
@ -81,6 +82,11 @@ public function updateProfilePicture(Request $request)
|
|||
// Process the uploaded file and update the user's profile picture
|
||||
$user = Auth::user();
|
||||
|
||||
// Hapus gambar lama jika ada
|
||||
if ($user->profile_picture) {
|
||||
Storage::disk('public')->delete($user->profile_picture);
|
||||
}
|
||||
|
||||
// Store the uploaded file and update the user's profile picture
|
||||
if ($request->hasFile('profile_picture')) {
|
||||
$imagePath = $request->file('profile_picture')->store('profile_pictures', 'public');
|
||||
|
|
Loading…
Reference in New Issue