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

后端 未结 5 2041
栀梦
栀梦 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:32

    This is example on VUE JS: preview PICTURE

    Example SOURCE CODE - DRAG-DROP _part

    Example with RENDERing & createObjectURL() using VIDEO.js

    p.s. i just want to improve "Pragya Sriharsh" solution:

    const = isVideo = filename =>'m4v,avi,mpg,mov,mpg,mpeg'
    .split(',')
    .includes( getExtension(filename).toLowerCase() )
    

    And .. please don't use JQuery, it's now 2k19:-);

    -> So:

    const getExtension = filename => {
        const parts = filename.split('.');
        return parts[parts.length - 1];
    }
    

    ... And let the rest of the work will be done by Webpack 4!

提交回复
热议问题