私の目標は、ビデオと画像のドラッグアンドドロップアップロードボックスを使用して、ボックスの正確な形状とサイズでファイルを埋め込みます。あなたはここにスニペットを見ることができますプレビュー付きの画像/動画をドラッグ&ドロップでアップロードする
は同じボックスにビデオのアップロードのための同じ機能を追加する方法を、把握することはできません。助けていただければ幸いです。
ここに抜粋です:
var imageLoader = document.getElementById('filePhoto');
imageLoader.addEventListener('change', handleImage, false);
function handleImage(e) {
var reader = new FileReader();
reader.onload = function (event) {
$('.uploader img').attr('src',event.target.result);
}
reader.readAsDataURL(e.target.files[0]);
}
.uploader {position:relative; overflow:hidden; width:300px; height:350px; background:#f3f3f3; border:2px dashed #e8e8e8;}
#filePhoto{
position:absolute;
width:300px;
height:400px;
top:-50px;
left:0;
z-index:2;
opacity:0;
cursor:pointer;
}
.uploader img{
position:absolute;
width:302px;
height:352px;
top:-1px;
left:-1px;
z-index:1;
border:none;
}
<div class="uploader" onclick="$('#filePhoto').click()">
click here or drag here your images for preview and set userprofile_picture data
<img src=""/>
<input type="file" name="userprofile_picture" id="filePhoto" />
</div>
これは示唆であり、修正/回答ではないので、コメントではなく回答として投稿してください。 – NewToJS