How can I set preview of video file, selecting from input type='file'

后端 未结 5 2028
栀梦
栀梦 2020-12-01 00:32

In one of my module, I need to browse video from input[type=\'file\'], after that I need to show selected video before starting upload.

I am using basic HTML tag to

5条回答
  •  北海茫月
    2020-12-01 01:23

    Lets make it easy

    HTML:

    
    


    JS:

    function readVideo(input) {
    
    if (input.files && input.files[0]) {
        var reader = new FileReader();
    
        reader.onload = function(e) {
    
            $('.myvideo').attr('src', e.target.result);
        };
    
        reader.readAsDataURL(input.files[0]);
    }
    }
    

提交回复
热议问题