File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -1144,17 +1144,24 @@ public function importData(Request $request)
11441144 $ sanitizedText = strip_tags_except_allowed_protocols ($ sanitizedText );
11451145 $ user ->littlelink_description = $ sanitizedText ;
11461146 }
1147+
1148+ $ allowedExtensions = array ('jpeg ' , 'jpg ' , 'png ' , 'webp ' );
1149+ $ userExtension = strtolower ($ userData ['image_extension ' ]);
1150+
11471151 if (isset ($ userData ['image_data ' ])) {
1152+ if (in_array ($ userExtension , $ allowedExtensions )) {
11481153 // Decode the image data from Base64
11491154 $ imageData = base64_decode ($ userData ['image_data ' ]);
11501155
11511156 // Save the image to the correct path with the correct file name and extension
1152- $ filename = $ user ->id . '. ' . $ userData [ ' image_extension ' ] ;
1153- file_put_contents (base_path ('img/ ' . $ filename ), $ imageData );
1157+ $ filename = $ user ->id . '. ' . $ userExtension ;
1158+ file_put_contents (base_path ('assets/ img/ ' . $ filename ), $ imageData );
11541159
11551160 // Update the user's image field with the correct file name
11561161 $ user ->image = $ filename ;
1162+ }
11571163 }
1164+
11581165 $ user ->save ();
11591166
11601167 // Delete all links for the authenticated user
You can’t perform that action at this time.
0 commit comments