imagekit-developer / imagekit-react

React SDK for using ImageKit.io
https://imagekit.io
MIT License
102 stars 28 forks source link

How to check file size BEFORE uploading to server? #84

Closed imagekitio closed 2 years ago

imagekitio commented 2 years ago

Something like this

<form action="/target" class="dropzone" id="my-great-dropzone"></form>

<script>
  Dropzone.options.myGreatDropzone = { // camelized version of the `id`
    paramName: "file", // The name that will be used to transfer the file
    maxFilesize: 2, // MB
    accept: function(file, done) {
      if (file.name == "justinbieber.jpg") {
        done("Naha, you don't.");
      }
      else { done(); }
    }
  };
</script>
imagekitio commented 2 years ago

Fixed in version 2.0.0. Use validateFile prop and return true or false based on file attributes.