Need to display error message quickly for file upload
Question
Application Type
Reactive

Hi,

I want to restrict user while uploading the file up to 20MB. File Uploading, saving functionality is working fine. But I select the file whose file size is 700MB / 1GB then it takes too much time to display File Size Error Message. Sometime it display

. My requirement is as soon as I select the file if it's size is more than specified size then it shows an error message quickly.


thanks


Solution

Hi Shaun11,

Added to the above answers, you can use the client side JS to get the filesize

step1: add the below js in the Upload1OnChange action

var fileUploader = document.querySelector(".upload input");

if (fileUploader){ 

    $parameters.FileSize = fileUploader.files[0].size;

    }

Step2 : Check whether the filesize is valid or not

Hope this helps!

Regards,

Ellakkiya.S

Hi Sarvanan & Ellakkiya,

thanks for reply. Both code are working fine if the file size is less then 1GB. For more than 1 Gb my page crashed and shows me below error. 



Solution

Hi Shaun,

Please try the client-side approach of validating file size using JS. I have attached the OML and URL for reference,

Hope it helps!

URL : https://saravanan-gamechanger.outsystemscloud.com/TEST/FileUploadValidation?_ts=637614840272265752

Regards,
Saravanan Santhanam.

FileValidation10072021.oml

Hello Shaun,

I have just attached two components here

1) hi upload file size - which will return you the upload size so if it's great then 20MB you give error at validation time

2)dynamic file validation- which will direct validate the file as per your requirement 

So please check those link 

https://www.outsystems.com/forge/component-overview/10007/hi-upload-file-size

https://www.outsystems.com/forge/component-overview/6073/dynamic-file-validation

Hope this will helps you.

Thanks and regards,

Akshay Deshpande.

Solution

Hi Shaun,

Please try the client-side approach of validating file size using JS. I have attached the OML and URL for reference,

Hope it helps!

URL : https://saravanan-gamechanger.outsystemscloud.com/TEST/FileUploadValidation?_ts=637614840272265752

Regards,
Saravanan Santhanam.

FileValidation10072021.oml

Solution

Hi Shaun11,

Added to the above answers, you can use the client side JS to get the filesize

step1: add the below js in the Upload1OnChange action

var fileUploader = document.querySelector(".upload input");

if (fileUploader){ 

    $parameters.FileSize = fileUploader.files[0].size;

    }

Step2 : Check whether the filesize is valid or not

Hope this helps!

Regards,

Ellakkiya.S

Hi Sarvanan & Ellakkiya,

thanks for reply. Both code are working fine if the file size is less then 1GB. For more than 1 Gb my page crashed and shows me below error. 



Yes,  it crashed. But I'll refer your references


Thanks

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.