File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
app/code/Magento/Customer/Model/Metadata/Form Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -182,7 +182,7 @@ protected function _validateByRules($value)
182
182
{
183
183
$ label = $ value ['name ' ];
184
184
$ rules = $ this ->getAttribute ()->getValidationRules ();
185
- $ extension = $ this ->fileProcessor -> getStat ($ value ['name ' ])[ ' extension ' ] ;
185
+ $ extension = $ this ->getFileExtension ($ value ['name ' ]);
186
186
$ fileExtensions = ArrayObjectSearch::getArrayElementByName (
187
187
$ rules ,
188
188
'file_extensions '
@@ -220,6 +220,20 @@ protected function _validateByRules($value)
220
220
return [];
221
221
}
222
222
223
+ /**
224
+ * Get file extension from the file if it exists, otherwise, get from filename.
225
+ *
226
+ * @param string $fileName
227
+ * @return string
228
+ */
229
+ private function getFileExtension (string $ fileName ): string
230
+ {
231
+ if ($ this ->fileProcessor ->isExist ($ fileName )) {
232
+ return $ this ->fileProcessor ->getStat ($ fileName )['extension ' ];
233
+ }
234
+ return pathinfo ($ fileName , PATHINFO_EXTENSION );
235
+ }
236
+
223
237
/**
224
238
* Helper function that checks if the file was uploaded.
225
239
*
You can’t perform that action at this time.
0 commit comments