Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File Upload - Allow uploading valid files and display an error message in case of invalid files at the same time #7314

Closed
JaneSjs opened this issue Nov 9, 2023 · 1 comment · Fixed by #7326
Assignees
Labels
enhancement user issue An issue or bug reported by users
Milestone

Comments

@JaneSjs
Copy link
Contributor

JaneSjs commented Nov 9, 2023

User Issue: T15217 - Add error message on the file preview
https://surveyjs.answerdesk.io/internal/ticket/details/T15217


Usage scenario: a user is allowed to upload mulitple files to a File Upload question. When a user uploads an invalid file, we send the options.callback('error', 'Error message') function to notify the user about an invalid file uploading attempt. However, if the user uploads multiple files - some of them valid, and others are invalid, it is impossible to simultaneously send valid files using options.callback('success', validFiles) and inform users about an invalid file uploading attempt using the options.callback('error').

@JaneSjs
Copy link
Contributor Author

JaneSjs commented Nov 10, 2023

@tsv2013, a customer also requests to have an option to specify multiple errors within the options.callback function.

Say that I try to upload at once two invalid files 'a.exe' and 'b.txt' I want to display this error :
Uploading 'a.exe' failed. reason : Type not allowed.
Uploading 'b.txt' failed. Reason : Empty file.

I believe that it would work if it would be possible to exdend an API and adding an option to specify an array or errors as a first parameter.

const errors = [
'Uploading 'a.exe' failed. reason : Type not allowed.',
'Uploading 'b.txt' failed. Reason : Empty file._'
];
const validFiles = [
  //.. An array of valid files
]
options.callback(errors, validFiles);

tsv2013 pushed a commit that referenced this issue Nov 13, 2023
…y an error message in case of invalid files at the same time - fixed f-test
tsv2013 pushed a commit that referenced this issue Nov 23, 2023
…n error message in case of invalid files at the same time - Updated error message text
tsv2013 added a commit that referenced this issue Nov 23, 2023
…y an error message in case of invalid files at the same time (#7326)

* Resolved #7314 - File Upload - Allow uploading valid files and display an error message in case of invalid files at the same time

* Work for #7314 - File Upload - Allow uploading valid files and display an error message in case of invalid files at the same time - fixed f-test

* Work for#7314 - File Upload - Allow uploading valid files and display an error message in case of invalid files at the same time - Changed API

* Update options.callback description

* Fixed #7314 - File Upload - Allow uploading valid files and display an error message in case of invalid files at the same time - Updated error message text

---------

Co-authored-by: tsv2013 <[email protected]>
Co-authored-by: RomanTsukanov <[email protected]>
@OlgaLarina OlgaLarina added this to the v1.9.119 milestone Nov 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement user issue An issue or bug reported by users
Projects
None yet
3 participants