Skip to content

Commit f6c6881

Browse files
authored
[4.x] Front-end form asset field php file validation (#8968)
1 parent e609fe0 commit f6c6881

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
@@ -177,7 +177,11 @@ protected function extraRules($fields)
177177
return $field->fieldtype()->handle() === 'assets';
178178
})
179179
->mapWithKeys(function ($field) {
180-
return [$field->handle().'.*' => 'file'];
180+
return [$field->handle().'.*' => ['file', function ($attribute, $value, $fail) {
181+
if (in_array(trim(strtolower($value->getClientOriginalExtension())), ['php', 'php3', 'php4', 'php5', 'phtml'])) {
182+
$fail(__('validation.uploaded'));
183+
}
184+
}]];
181185
})
182186
->all();
183187

0 commit comments

Comments
 (0)