// 图片上传测试用 $("#photofile").bind("change", function() { var objURL = getObjectURL(this.files[0]); if(objURL) { $("#defaultimg").attr("src", objURL); } }); function getObjectURL(file) { var url = null; if(window.URL != undefined) { url = window.URL.createObjectURL(file); } else if (window.webkitURL != undefined) { url = window.webkitURL.createObjectURL(file); } return url; } // 图片上传测试用 END
<input type="file" name="photoUrlFile" class="btn" id="photofile" style="z-index:1;filter:alpha(opacity=0);opacity:0;float:left;position:absolute;left:0px;cursor:pointer;outline:none" /> <img src="/vst_back/img/u146.png" id="defaultimg" style="vertical-align:middle;max-height:120px;max-150px;" />
判断是否有文件---
if(document.getElementById("photofile").files.length == 0) { $.alert("封面图片未上传"); return; }
图片提交--
/* $("#dataForm").ajaxSubmit({ type: "POST", url: "/vst_back/prod/prodVideo/addProductVideo.do", success: function(data) { var result = data.success; var msg = data.message; if( result == true) { $.alert(msg, function() { window.location.href = "/vst_back/prod/prodVideo/showProductVideo.do?productId=${productId!''}&categoryId=${categoryId!''}"; }); } else { $.alert(msg); } }, error: function(e) { $.alert(e.message); } }); */