Skip to content
Snippets Groups Projects

Add client side validation for file size during file upload.

Open Oleksandr Syvyi requested to merge issue/drupal-2533896:2533896-make-a-check into 11.x
3 unresolved threads

Closes #2533896

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Oleksandr Syvyi resolved all threads

    resolved all threads

  • added 1 commit

    Compare with previous version

  • Oleksandr Syvyi resolved all threads

    resolved all threads

  • added 1 commit

    Compare with previous version

  • Oleksandr Syvyi resolved all threads

    resolved all threads

  • added 1 commit

    Compare with previous version

  • Oleksandr Syvyi resolved all threads

    resolved all threads

  • added 1 commit

    • e71ff0b9 - Use the '**' operator instead of 'Math.pow'.

    Compare with previous version

  • Oleksandr Syvyi resolved all threads

    resolved all threads

  • added 1 commit

    Compare with previous version

  • Oleksandr Syvyi resolved all threads

    resolved all threads

  • added 1 commit

    Compare with previous version

  • Oleksandr Syvyi resolved all threads

    resolved all threads

  • added 1 commit

    Compare with previous version

  • Oleksandr Syvyi resolved all threads

    resolved all threads

  • added 1 commit

    Compare with previous version

  • 27 27 $(once('fileValidate', $context.find(selector))).on(
    28 28 'change.fileValidate',
    29 29 { extensions: elements[selector] },
    30 Drupal.file.validateExtension,
  • 146 * Client-side file input validation of file extensions.
    146 * Client-side file input validation of file extensions and file size.
    147 147 *
    148 * @name Drupal.file.validateExtension
    148 * @name Drupal.file.validateExtensionAndSize
    149 149 *
    150 150 * @param {jQuery.Event} event
    151 151 * The event triggered. For example `change.fileValidate`.
    152 152 */
    153 validateExtension(event) {
    153 validateExtensionAndSize(event) {
    154 154 event.preventDefault();
    155 const file = this.files[0];
    156
    157 // Formats bytes to human friendly unit.
    158 function humanFileSize(size) {
  • 184 191 event.stopImmediatePropagation();
    185 192 }
    186 193 }
    194
    195 // Validate filesize.
    196 if (file.size > drupalSettings.file.max_size) {
    Please register or sign in to reply
    Loading