[pve-devel] [PATCH v2 manager 5/5] ui/UplaodToStorage: check file extension
Lorenz Stechauner
l.stechauner at proxmox.com
Thu Jul 22 15:06:31 CEST 2021
Signed-off-by: Lorenz Stechauner <l.stechauner at proxmox.com>
---
www/manager6/window/UploadToStorage.js | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/www/manager6/window/UploadToStorage.js b/www/manager6/window/UploadToStorage.js
index c63de16a..3f4596ce 100644
--- a/www/manager6/window/UploadToStorage.js
+++ b/www/manager6/window/UploadToStorage.js
@@ -156,6 +156,20 @@ Ext.define('PVE.window.UploadToStorage', {
checksum.allowBlank = false;
}
},
+
+ filenameChange: function(field) {
+ const view = this.getView();
+ const filename = field.getValue();
+ for (let ext of view.acceptedExtensions[view.content]) {
+ if (filename.endsWith(ext)) {
+ field.setValidation();
+ field.validate();
+ return;
+ }
+ }
+ field.setValidation("wrong file extension");
+ field.validate();
+ },
},
items: [
@@ -193,6 +207,9 @@ Ext.define('PVE.window.UploadToStorage', {
bind: {
value: '{filename}',
},
+ listeners: {
+ change: 'filenameChange',
+ },
},
{
xtype: 'displayfield',
--
2.30.2
More information about the pve-devel
mailing list