From 5c698f45bc8e955a94a9d7a7a72e8b883aa06b36 Mon Sep 17 00:00:00 2001 From: Jonathan Rochkind Date: Thu, 7 Feb 2019 11:55:44 -0500 Subject: [PATCH] Only allow one file selection for 'cover' non-multiple input The "cover" photo only accepts one file, but was resulting in a file open dialog that let you pick multiple files -- all but the first would be ignored by subsequent JS code. This now demonstrates how to tell uppy to (tell the OS file selection dialog to) only allow one file selection. Since we're just using the html "multiple" attribute, I'm not sure why uppy doesn't do this already as a default, it could conceivably be a feature PR to uppy. But in the meantime, why not have the demo be more solid and take care of this. Without this change, the demo lets me choose more than one file for 'cover' but they are all ignored; with this change, the demo file open dialog for 'cover' only lets me choose one file. (MacOS Chrome). --- app/assets/javascripts/application.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 769db51..e101dec 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -14,6 +14,7 @@ function fileUpload(fileInput) { autoProceed: true, restrictions: { allowedFileTypes: fileInput.accept.split(','), + maxNumberOfFiles: (fileInput.multiple ? undefined : 1), } }) .use(Uppy.FileInput, {