Remove selected files using jQuery
<p>Tried show selected images and remove images on click the images using jQuery. </p>

<p>removing image on click working fine, actually problem is it doesn't remove from the form .<br></p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).ready(function() {
  /*multiple image preview first input*/

  $("#files").on("change", handleFileSelect);

  selDiv = $("#selectedFiles");
  $("#myForm").on("submit", handleForm);

  $("body").on("click", ".selFile", removeFile);

  /*end image preview */
});


var selDiv = "";
// var selDivM="";
var storedFiles = [];

function handleFileSelect(e) {

  var files = e.target.files;
  var filesArr = Array.prototype.slice.call(files);
  var device = $(e.target).data("device");
  filesArr.forEach(function(f) {

    if (!f.type.match("image.*")) {
      return;
    }
    storedFiles.push(f);

    var reader = new FileReader();
    reader.onload = function(e) {
      var html = "&lt;div&gt;&lt;img src=\"" + e.target.result + "\" data-file='" + f.name + "' class='selFile' title='Click to remove'&gt;" + f.name + "&lt;br clear=\"left\"/&gt;&lt;/div&gt;";
      $("#selectedFiles").append(html);
    }
    reader.readAsDataURL(f);
  });

}

function handleForm(e) {
  e.preventDefault();
  var data = new FormData();

  for (var i = 0, len = storedFiles.length; i &lt; len; i++) {
    data.append('files', storedFiles[i]);
  }

  var xhr = new XMLHttpRequest();
  xhr.open('POST', 'handler.cfm', true);

  xhr.onload = function(e) {
    if (this.status == 200) {
      console.log(e.currentTarget.responseText);
      alert(e.currentTarget.responseText + ' items uploaded.');
    }
  }

  xhr.send(data);
}

function removeFile(e) {
  var file = $(this).data("file");
  for (var i = 0; i &lt; storedFiles.length; i++) {
    if (storedFiles[i].name === file) {
      storedFiles.splice(i, 1);
      break;
    }
  }
  $(this).parent().remove();
}</code></pre>
<pre class="snippet-code-css lang-css prettyprint-override"><code>#selectedFiles img
{
  max-width: 200px;
  max-height: 200px;
  float: left;
  margin-bottom: 10px;
}
#userActions input {
  width: auto;
  margin: auto;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"&gt;&lt;/script&gt;
&lt;form action="index.php" id="myForm" name="myForm" enctype="multipart/form-data" method="post" accept-charset="utf-8"&gt;
  desktop:
  &lt;input type="file" id="files" name="files" multiple&gt;
  &lt;div id="selectedFiles"&gt;&lt;/div&gt;
  &lt;br/&gt;
&lt;/form&gt;</code></pre>
</div>
</div>

see this:
<a href="https://jsfiddle.net/dvy10ms7/1/" rel="noreferrer">https://jsfiddle.net/dvy10ms7/1/</a></p>

<p><strong>see the images</strong></p>

<p><a href="https://i.stack.imgur.com/ywLUP.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ywLUP.png" alt="enter image description here"></a></p>

<p><a href="https://i.stack.imgur.com/UtaBa.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/UtaBa.jpg" alt="enter image description here"></a></p>

<p><a href="https://i.stack.imgur.com/F6UpR.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/F6UpR.jpg" alt="enter image description here"></a></p>