Disable File Upload during upload processing

How do I disable/enable a file upload control using javascript?

5 Replies 1 reply marked as answer

PM Ponmani Murugaiyan Syncfusion Team October 6, 2020 12:24 PM UTC

Hi Mike, 

Greetings from Syncfusion support. 

Query: How do I disable/enable a file upload control using javascript? 
 
You can enable /disable the Uploader component using the Enabled property as like below code snippet. 

@{ 
    var asyncSettings = new Syncfusion.EJ2.Inputs.UploaderAsyncSettings { SaveUrl = "https://ej2.syncfusion.com/services/api/uploadbox/Save", RemoveUrl = "https://ej2.syncfusion.com/services/api/uploadbox/Remove" }; 
} 
 
<ejs-uploader id="uploadFiles" asyncSettings="@asyncSettings" autoUpload="false"></ejs-uploader> 
 
<button id="myBtn">Enable/Disable</button> 
 
<script> 
    var uploadObj; 
    var isEnabled = true; 
    document.addEventListener('DOMContentLoaded', function () { 
        document.getElementById("myBtn").addEventListener("click", ClickHandler); 
        uploadObj = document.getElementById("uploadFiles").ej2_instances[0]; 
    })  
 
    function ClickHandler() { 
        if (uploadObj.enabled) { 
            uploadObj.enabled = false; 
        } else { 
            uploadObj.enabled = true; 
        } 
} 
</script> 
 
 
 
Kindly check with the above suggestion meets your requirement. Please get back us if you need further assistance. 
 
Regards, 
Ponmani M 


Marked as answer

MR Mike Rowley October 6, 2020 02:37 PM UTC

Excellent, thank you!


PM Ponmani Murugaiyan Syncfusion Team October 7, 2020 04:17 AM UTC

Hi Mike, 
  
Thanks for the update. Please get back us if you need further assistance. 
  
Regards, 
Ponmani M  



AK Aman kumar May 3, 2023 03:16 PM UTC

hi how we not allowed to upload specific file extension for user from file uploader



MR Mallesh Ravi Chandran Syncfusion Team May 4, 2023 03:25 PM UTC

Hi Aman,

To restrict specific file extensions, you can use the 'allowedExtensions' property of the uploader component. This property allows you to specify the extensions of the file types allowed and separate them with commas. For example, if you only want to allow image files with extensions '.jpg' and '.png', you can set the allowedExtensions property to “.jpg,.png”.


For more information on this topic, please refer to below documentation and API reference.

Documentation : https://ej2.syncfusion.com/aspnetcore/documentation/uploader/validation#file-type

API Reference :
allowedExtensions

Regards,

Mallesh


Loader.
Up arrow icon