Added the 'required' attribute to the input file n the upload file form modal. Added a validation for the UserFilesController if the user doesn't select any file to upload [ch16471].

This commit is contained in:
Ivan Nieto Vivanco 2021-05-27 15:48:13 -05:00
parent 7d5a9180e6
commit 9f944ad497
2 changed files with 5 additions and 1 deletions

View file

@ -33,6 +33,10 @@ class UserFilesController extends Controller
$logActions = []; $logActions = [];
$files = $request->file('file'); $files = $request->file('file');
if (is_null($files)){
return redirect()->back()->with('error', trans('admin/users/message.upload.nofiles'));
}
foreach($files as $file) { foreach($files as $file) {
$extension = $file->getClientOriginalExtension(); $extension = $file->getClientOriginalExtension();
$filename = 'user-' . $user->id . '-' . str_random(8); $filename = 'user-' . $user->id . '-' . str_random(8);

View file

@ -19,7 +19,7 @@
<label class="btn btn-default"> <label class="btn btn-default">
{{ trans('button.select_file') }} {{ trans('button.select_file') }}
<input type="file" name="file[]" multiple="true" class="js-uploadFile" id="uploadFile" data-maxsize="{{ \App\Helpers\Helper::file_upload_max_size() }}" accept="image/*,.csv,.zip,.rar,.doc,.docx,.xls,.xlsx,.xml,.lic,.xlsx,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,text/plain,.pdf,application/rtf" style="display:none"> <input type="file" name="file[]" multiple="true" class="js-uploadFile" id="uploadFile" data-maxsize="{{ \App\Helpers\Helper::file_upload_max_size() }}" accept="image/*,.csv,.zip,.rar,.doc,.docx,.xls,.xlsx,.xml,.lic,.xlsx,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,text/plain,.pdf,application/rtf" style="display:none" required>
</label> </label>
</div> </div>