4

I have input type "file".

<input type="file" class="someCssClass"
        (drop)="onImageDrop($event)" required>

I want to restrict user so that they can't click on the file box to select a file to upload. Only drag and drop should be permitted on the file input box.

But how can I restrict the user? Please help as user is able to click on the file input box and browse folder option is coming on click which I don't want. Drag and Drop is working as expected and I am fine with that.

1 Answer 1

2

Maybe something like this would work ((click)="$event.preventDefault()"):

<input type="file" class="someCssClass" (drop)="onImageDrop($event)" 
   (click)="$event.preventDefault()" required>

If you want to make it a bit better for the user, make a function that shows an error/explanation at the same time it is cancelling the event.

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

1 Comment

It worked by adding (click)="$event.preventDefault()" . Thank you very much for the answer.

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.