From baedc9c7e71b9cab97eb81044b6787bca6f91485 Mon Sep 17 00:00:00 2001 From: Rob Lister Date: Wed, 20 Apr 2022 15:13:45 +0100 Subject: [PATCH] Check filename has extension. Make more obvious. A follow up to: https://github.com/inex/IXP-Manager/issues/686 Users still seem to be uploading files without extensions, by typing something in the "Name" field, not realising this is used as the actual file name. Possibly because this is the first field, and it's before the file upload button. If name is not completed, the filename is completed automatically. File then won't open when downloaded because it has no extension. - This fix changes "Name" to "File Name" to make it more obvious. - Validate the file name is "(something).extn" - Move upload file button before File Name so the user does this bit first. (Then will see the name is filled in for them.) Can't see a way to make the help text visible by default (it's hidden unless the user clicks the help button.) --- .../docstore-customer/file/upload.foil.php | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/resources/views/docstore-customer/file/upload.foil.php b/resources/views/docstore-customer/file/upload.foil.php index 770d5b430..2253918e7 100644 --- a/resources/views/docstore-customer/file/upload.foil.php +++ b/resources/views/docstore-customer/file/upload.foil.php @@ -21,13 +21,23 @@ ->actionButtonsCustomClass( "grey-box") ->class('col-8') ->rules([ - 'name' => 'required|max:100' + 'name' => ['required', 'max:100', 'match:"/^(?:^..*)\.\w{1,5}$/"'] ]) ?> + + id( 'uploadedFile' ) + ->label( ( $t->file ? 'Replace' : 'Upload' ) . ' File' ) + ->class( 'form-control border-0 shadow-none' ) + ->multiple( false ) + ->blockHelp( $t->file ? "You only need to choose a file here if you wish to replace the existing one. Do not select a file to edit other details but leave the current file in place." + : "Select the file you wish to upload." ); + ?> id('name') - ->label( 'Name' ) + ->label( 'File Name' ) + ->title( 'File name including extension' ) ->blockHelp( "The name of the file (this is as it appears on listings in the web interface rather than on the filesystem). " . "This is also the name the downloaded file will have - so use the appropriate extension."); ?> @@ -55,15 +65,6 @@ ->blockHelp( "The minimum privilege a user is required to have to view and download the file." ); ?> - id( 'uploadedFile' ) - ->label( ( $t->file ? 'Replace' : 'Upload' ) . ' File' ) - ->class( 'form-control border-0 shadow-none' ) - ->multiple( false ) - ->blockHelp( $t->file ? "You only need to choose a file here if you wish to replace the existing one. Do not select a file to edit other details but leave the current file in place." - : "Select the file you wish to upload." ); - ?> -
@@ -128,4 +129,4 @@ }); }); -append() ?> \ No newline at end of file +append() ?>