0

I have a form with <input type="file">. I was doing a couple of tests, I found out that on Chrome when someone chooses a file and decides to change the file they had chosen already, and press the cancel button the file path of the previous file disappears or sometimes when you open a new tab while on the form.

How can this problem be solved?

<!DOCTYPE html>
<html>
<head>
 <title></title>
</head>
<body>


 <form>
  <input type="file" name="">
 </form>

</body>
</html>
Jerry D
  • 381
  • 11
  • 25
lawkunchi
  • 19
  • 2
  • 8
  • I think it's by design, although not a good design. It's offers you a way to **reset** the input element. – Leo Mar 12 '19 at 14:16
  • It is default behavior of file input control, you can not alter it - it may be due to security reason – Suresh Negi Mar 12 '19 at 14:48
  • Possible duplicate of [input type="file", clearing file after clicking cancel in chrome](https://stackoverflow.com/questions/17798993/input-type-file-clearing-file-after-clicking-cancel-in-chrome) – Jerry D Mar 12 '19 at 15:02

1 Answers1

0

You cannot change it, it is impossible. This is something that it does by default. It doesn't let you detect when the cancel button is clicked, so you can't do anything about it. It's all because of the browser design.

Jerry D
  • 381
  • 11
  • 25