4

i have to set default image path into formbuilder but given exception. i have also try with empty string and null.

 buildForm() {
        this.userForm = this.formBuilder.group({
            location_id: this.formBuilder.control(null),
            image: this.formBuilder.control('assets/images-demo/avatars/user.png'),
        });
    }

ERROR DOMException: Failed to set the 'value' property on 'HTMLInputElement': This input element accepts a filename, which may only be programmatically set to the empty string.

1
  • 1
    I don't think this is possible. It is essential for browser security that the value cannot be set programmatically but only by a user action. Otherwise Javascript code would be able to retrieve files from the user's device. Exception: you can set it to the empty value, which is harmless. Commented May 3, 2017 at 13:22

1 Answer 1

3

Error says that it is not possible to set input programmatically for type='file'.

Only empty string is possible.

Many posts say that this is a security issue to change the input value for file type.

jQuery, Select Input FILE and also set it to another INPUT

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.