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)
1144
1144
$ sanitizedText = strip_tags_except_allowed_protocols ($ sanitizedText );
1145
1145
$ user ->littlelink_description = $ sanitizedText ;
1146
1146
}
1147
+
1148
+ $ allowedExtensions = array ('jpeg ' , 'jpg ' , 'png ' , 'webp ' );
1149
+ $ userExtension = strtolower ($ userData ['image_extension ' ]);
1150
+
1147
1151
if (isset ($ userData ['image_data ' ])) {
1152
+ if (in_array ($ userExtension , $ allowedExtensions )) {
1148
1153
// Decode the image data from Base64
1149
1154
$ imageData = base64_decode ($ userData ['image_data ' ]);
1150
1155
1151
1156
// 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 );
1154
1159
1155
1160
// Update the user's image field with the correct file name
1156
1161
$ user ->image = $ filename ;
1162
+ }
1157
1163
}
1164
+
1158
1165
$ user ->save ();
1159
1166
1160
1167
// Delete all links for the authenticated user
You can’t perform that action at this time.
0 commit comments