Skip to content

Commit 098ef80

Browse files
authored
Front-end form asset field php file validation (#8971)
1 parent 36d8a5c commit 098ef80

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Diff for: src/Http/Controllers/FormController.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,11 @@ protected function extraRules($fields)
164164
return $field->fieldtype()->handle() === 'assets';
165165
})
166166
->mapWithKeys(function ($field) {
167-
return [$field->handle().'.*' => 'file'];
167+
return [$field->handle().'.*' => ['file', function ($attribute, $value, $fail) {
168+
if (in_array(trim(strtolower($value->getClientOriginalExtension())), ['php', 'php3', 'php4', 'php5', 'phtml'])) {
169+
$fail(__('validation.uploaded'));
170+
}
171+
}]];
168172
})
169173
->all();
170174

0 commit comments

Comments
 (0)