[英]Image upload with Drag & Drop HTML
Hi I have a problem with the drag and drop, I want to extend the size of input at the entire father's div I don't know why but the input is set under the drag and drop div. 嗨,我在拖放时遇到问题,我想在整个父亲的div处扩展输入的大小,我不知道为什么,但是输入是在拖放div下设置的。 Anyone can help me? 有人可以帮助我吗?
I made a fiddle but it doesn't work... https://jsfiddle.net/Porcy/jmbcdLbo/ 我做了一个小提琴,但是没用... https://jsfiddle.net/Porcy/jmbcdLbo/
.uploader{
text-align: center;
padding: 1em 0;
margin: 1em 0;
color: #555;
border: 2px dashed #888;
border-radius: 7px;
cursor: default;
}
#filePhoto{
position: absolute;
opacity:0;
cursor:pointer;
}
<div onclick="$('#filePhoto').click()" class="uploader">
click here or drag here your images for preview and set userprofile_picture data
<input type="file" size="32" name="userprofile_picture" id="filePhoto" />
</div>
var imageLoader = document.getElementById('filePhoto');
imageLoader.addEventListener('change', handleImage, false);
function handleImage(e) {
var reader = new FileReader();
reader.onload = function (event) {
$('#blah').attr('src',event.target.result);
}
reader.readAsDataURL(e.target.files[0]);
}
Try this CSS 试试这个CSS
.uploader {
position: relative;
text-align: center;
padding: 1em 0;
margin: 1em 0;
color: #555;
border: 2px dashed #888;
border-radius: 7px;
cursor: default;
}
#filePhoto {
position: absolute;
opacity: 0;
cursor: pointer;
left: 0;
right: 0;
width: 100%;
top: 0;
bottom: 0;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.