1
如何获取这些图像值,特别是当我拖动图像时从控制台显示的名称,大小,类型。并将这些数据显示到我的特定格Javascript:如何获取此图像数据
File {name: "free-windows-10-wallpaper_050549897_263.jpg", lastModified:
1464238729860, lastModifiedDate: Thu May 26 2016 12:58:49 GMT+0800 (Malay
Peninsula Standard Time), webkitRelativePath: "", size: 1185535…}
lastModified : 1464238729860
lastModifiedDate :Thu May 26 2016 12:58:49 GMT+0800 (Malay Peninsula Standard Time)
name : "free-windows-10-wallpaper_050549897_263.jpg"
size : 1185535
type : "image/jpeg"
webkitRelativePath : ""
__proto__ : File
这是js代码。
var obj = $('.drag_me');
obj.on('dragover', function(e){
e.stopPropagation();
e.preventDefault();
$(this).css('border', '2px solid #39ADCD');
});
obj.on('drop', function(e){
e.stopPropagation();
e.preventDefault();
$(this).css('border', '2px dotted #39ADCD');
var files = e.originalEvent.dataTransfer.files;
var file = files[0]; //<-- I need to get the size, name, image type of this image
console.log(file);
//upload(file);
});
这样我就可以显示这些数据给我的HTML
<div class="drag_here">
<div class="drag_me">
<center id="center_html">
Drag image here
</center>
</div>
</div>
无法访问使用'file.name','file.lastModified',就在你的'//上传(文件)'了吗? –
@DavidR谢谢你,我明白了。 –