我尝试在输入文件中上传视频,然后我转换为base64 ..可以添加进度条而不是 readAsDataURL ?
代码与此示例类似: http://codepen.io/kilianso/pen/MKjYPx
<div>
<input type="file" accept="video/*" id="VidExp" name="VidExp">
<video preload="none" autoplay="autoplay" id="upload_vid" class="cstepVid" src="" alt=""></video>
</div>
$(document).ready(function(){
$('.upload_vid[src=""]').hide();
$('.upload_vid:not([src=""])').show();
});
function readURLVid(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#upload_vid').attr('src', e.target.result);
$('#preview_vid').attr('src', e.target.result);
};
reader.readAsDataURL(input.files[0]);
}
}
$("#VidExp").change(function() {
readURLVid(this);
});