From 86b5d325a2b631599b9091641a1009ea2c6cc87c Mon Sep 17 00:00:00 2001 From: Nikhil Kutinha <61931921+nikhilkutinha@users.noreply.github.com> Date: Wed, 12 May 2021 18:10:40 +0530 Subject: [PATCH] [2.x] Inertia - ensure file selection is not empty before updating profile photo preview (#782) * Update UpdateProfileInformationForm.vue * Update UpdateProfileInformationForm.vue Co-authored-by: Taylor Otwell --- .../js/Pages/Profile/UpdateProfileInformationForm.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/stubs/inertia/resources/js/Pages/Profile/UpdateProfileInformationForm.vue b/stubs/inertia/resources/js/Pages/Profile/UpdateProfileInformationForm.vue index 401a7945f..1f78fafbe 100644 --- a/stubs/inertia/resources/js/Pages/Profile/UpdateProfileInformationForm.vue +++ b/stubs/inertia/resources/js/Pages/Profile/UpdateProfileInformationForm.vue @@ -121,13 +121,17 @@ }, updatePhotoPreview() { + const photo = this.$refs.photo.files[0]; + + if (! photo) return; + const reader = new FileReader(); reader.onload = (e) => { this.photoPreview = e.target.result; }; - reader.readAsDataURL(this.$refs.photo.files[0]); + reader.readAsDataURL(photo); }, deletePhoto() {