Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
65
How to implement upload control.
posted

How to implement file upload control with validation like size and file type validation.

  • 460
    Offline posted

    Hello Abdullah,

    Thank you for posting in our community.

    I have been looking into your question and to implement a file upload control, the IgxInputGroupComponent is used, which has an input field with the igxInput directive and its type is of file type.

    <igx-input-group>
        <input igxInput type="file"/>
    </igx-input-group>

    In order to achieve the described behavior, what I could suggest is to handle the change event of the input field, which is the default event coming from the input. When a file is uploaded and the event is fired, you can access this file and retrieve its name, size, type, etc. With these properties you can check if the file is larger than given sizes or if it is of a given type, as well as other validations. This way you will implement input control and validate the file according to given criteria.

    In addition, I have prepared a small sample illustrating my suggestion which could be found here. Please test it on your side and let me know how it behaves.

    If you require any further assistance on the matter, please let me know.

    Regards,

    Georgi Anastasov

    Entry Level Software Developer

    Infragistics