1
<input #fileInput hidden="true" type="file" accept="*" (onChange)="uploadFile($event)"/>

and in my component.ts

uploadFile(fileEvent){}
2
  • 1
    try to use multiple attribute in your input and check. <input #fileInput hidden="true" type="file" accept="*" (onChange)="uploadFile($event)" multiple/> Commented Oct 9, 2020 at 7:29
  • @FarhatZaman I don't want to use multiple, I want to restrict the user to select only one file, like abc.doc then our code should check and pick the abc.pdf along with abc.doc. Commented Oct 9, 2020 at 8:00

1 Answer 1

1

Javascript will not allow you to read a file that was not selected through file selector for security reasons. It would be a major security breach if you entered a web page and it could read randomly files in your system.

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.