//圖片預覽
function previewImage(file) {
var div = document.getElementById('preview');
div.innerHTML = "";
for (var i = 0; i < file.files.length; i++) {
//alert(file.files[i]);
var ndiv = document.createElement("div");
ndiv.style.height = "150px";
ndiv.style.width = "300px";
ndiv.style.cssFloat = "left";
var img = document.createElement("img");
//添加圖片描述,如何保存?
var textArea = document.createElement("textarea");
textArea.style.width = "100";
textArea.style.height = "95px";
ndiv.appendChild(img);
ndiv.appendChild(textArea);
alert(img);
img.id = "img" + i;
div.appendChild(ndiv);
img.width = 100;
img.height = 100;
}
照片上傳:
<input type="file" multiple="multiple" onchange="previewImage(this)" id="myimage" runat="server" class="btn btn-default" style="margin-left:40%;height:69px;width:280px"/>
http://www.jb51.net/html5/160920.html