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

Validate file size before upload #7383

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SahithiAmmana
Copy link

Fixes #7382

Short description of what this resolves:

This pull request addresses the issue where OpenEMR fails to display an error message when attempting to upload large files, leaving users unaware of the upload failure.

Changes proposed in this pull request:

  • Implemented client-side file size validation using JavaScript to prevent submission of files exceeding the maximum size limit.
  • Modified the upload form in "./templates/documents/general_upload.html" to incorporate the checkFileSize() JavaScript function.
  • Updated the "onsubmit" attribute of the form element to trigger the checkFileSize() function before form submission, ensuring validation occurs prior to data submission to the server.

unnamed

Copy link
Sponsor Member

@sjpadgett sjpadgett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for PR but it needs some changes

Comment on lines +20 to +21
totalSize += fileInput.files[i].size;
}
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MAX_FILE_SIZE is the maximum allowed size for each individual file, not the combined total size of all files.
So this verification is invalid for our purposes.

Comment on lines -14 to +35
<form class="form" method="post" enctype="multipart/form-data" action="{$FORM_ACTION}" onsubmit="return top.restoreSession()">
<form class="form" method="post" enctype="multipart/form-data" action="{$FORM_ACTION}" onsubmit="return checkFileSize()">
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You still need to run restoreSession before file check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lack of Feedback for Failed Uploads of Large Files
3 participants