Skip to main content

How to restrict images to particular size while uploading

Comments

1 comment

  • Raz Ziv

    Hi,

    Restricting the file size is possible when using our Upload Widget for client-side uploads. 
    You can include the 'maxFileSize' parameter when calling the widget, setting its value to 500000 (value should be provided in bytes).

    If the client will try and upload a larger file he/she will get back an error stating the max file size is exceeded and the upload will fail.

    Alternatively, you can choose to limit the dimensions of the image, so if exceeded, instead of failing the upload with an error, it will automatically scale down to the given dimensions while retaining aspect ratio and the upload request will succeed.

    However, using this method doesn't guarantee the uploaded file will be below a certain desired size (e.g. 500kb) as each image is different and one image that is scaled-down to given dimensions can result in a file size that is smaller than your threshold, while another image may slightly exceed it.
    This can be achieved using the limit cropping method as part of an incoming transformation.

    Let me know if you need further assistance with implementing any of the above-mentioned approaches.

    Best,
    Raz

    0

Post is closed for comments.