Detect a file select on the same file as previously selected

I have simple web app which lets a user select a file, and uploads it for them. If the upload fails, it tries again, 2 more times, to upload it.

I start the upload process when the change event happens on the input. I want this to happen every time they select a file, even if they select the same file twice in a row. (I have a good reason, not relevant here)

However, if they select the same file again, the change event does not happen. It only happens when the file input was previously empty, or pointed at a different file.

Is there a "a file has been selected" event which I can bind a function to, which doesn't necessitate a change?

Plain .js is fine, jQuery is already loaded in the project.

I'm looking for something like a "file selected" but there's nothing I can see.

reportEvent = function() {
  $('.form-box').append(
    '<p>The input change event fired for' + $('#fi').val() + '</p>'
  );
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="form-box">
  <input type="file" id="fi" onchange="reportEvent()">
</div>

Answers


This might help:

reportEvent = function() {
  $('.form-box').append(
    '<p>The input change event fired for' + $('#fi').val() + '</p>'
  );
   
  // Do some work here...

  $('#fi').val(''); // Reset file input to the initial state, so you can upload the same file again
}

Need Your Help

Solid FFmpeg wrapper for C#/.NET

c# .net video ffmpeg video-processing

I have been searching the web for some time for a solid FFmpeg wrapper for C#/.NET. But I have yet to come up with something useful. I have found the following three projects, but all of them apea...