If you want to upload photos or movies, how can you combine them? (same input)

this is the forecast for film sales

$("input[type=file]").change(function() {
   var input = $(this);
   if(!!this.files && !!this.files[0]) {
     var reader = new FileReader();
   reader.onload = function(e) {
       $("-sharppre" + input.prop("id").substr(4,2)).prop("src", e.target.result);
   }
   reader.readAsDataURL(this.files[0]);
 }
});

this is to add a movie movie.

$(document).on("change", ".file_multi_video", function(evt) {
  var $source = $("-sharpvideo_here");
  $(".video_show").show();
  $source[0].src = URL.createObjectURL(this.files[0]);
  $source.parent()[0].load();
});

it"s just that when I wrote at the beginning, the uploading of the film and the uploading of the photo were separate:

<input type="file" name="video" class="file_multi_video upload_cover" accept="video/*">
              <video autoplay muted class="video_show displayNone">
                <source src="<?=$editBlog["video"];?>" id="video_here">
              </video>

so there will be two uploads of input
, but I am all on the same

now.
<input type="file" id="file02" name="cover" class="upload_cover" accept="image/jpeg, image/png, image/jpg, video/*">

it"s just that I don"t know how to integrate uploading photos when using the first function
if it"s another function on the movie?
how can this be realized?
how to judge in input change? Or is there a better way?


in fact, it can be judged by the type of file.

  

by event.files [0] .type , it should be image/* and video/* .

Menu