视频上传
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> 视频上传 </title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-store">
<meta http-equiv="expires" content="0">
<meta http-equiv="Content-Type" content="text/html;charset=GBK">
</head>
<body>
<table width="100%" border="0" cellpadding="1" cellspacing="1" class="sj-word-2" bgcolor="#BCBCBC">
<tr>
<td width="100%" height="35" colspan="4" class="td-02">
<div id="file_div" style="width: 100%;">
从本地上传:
<html:file styleId="formFile" property="formFile" name="zxpttrainmanagerForm"
οnchange="uplaodSubmit();" size="50" ></html:file>
视频支持flv格式
</div>
<div id="tip_div" style="display: none;width: 100%;">
正在上传视频,请稍候!
</div>
</td>
</tr>
</table>
<script type="text/javascript">
var file_html="";
$(function() {
file_html=$("#file_div").html();
//alert(file_html);
$(window.parent.document.getElementById("toSaveBtn")).attr("disabled",false);
//延迟700毫秒后,再调整页面的高度
setTimeout(getHeight,500);
});
function getHeight() {
window.parent.document.getElementById("attacheFrame").height = document.body.scrollHeight
+ "px";
}
//提交上传具体资源
function uplaodSubmit() {
if (zxpttrainmanagerForm.formFile.value == "") {
alert("请选择具体资源");
zxpttrainmanagerForm.formFile.focus();
return;
} else {
if(!checkFile()){
return;
}
disableAll();
$("#file_div").hide();
$("#tip_div").show();
$(window.parent.document.getElementById("toSaveBtn")).attr("disabled",true);
zxpttrainmanagerForm.submit();
}
}
function deleteFile(obj, flag, id) {
if (confirm("删除后将无法恢复,您确认删除吗?")) {
var _url = "zxpxglFile.do?method=deleteFile&ai_id=" + id;
if (flag == "tmp") {
_url = "zxpxglFile.do?method=deleteFileTmp&id=" + id;
}
$.ajax({
url : _url,
cache : false,
success : function(data) {
if(id!="-1"){
if (data == "0") {
alert("删除失败!");
} else {
$(obj.parentNode.parentNode).remove(); // 删除当前节点的父节点的父节点
getHeight();
}
}
}
});
}
}
function checkFile() {
var filepath = $("#formFile").val();
var extStart=filepath.lastIndexOf(".");
var ext=filepath.substring(extStart,filepath.length).toUpperCase();
//alert(ext);
if (ext != ".FLV") {
alert("上传视频仅限于flv(FLV)格式的视频");
//alert(file_html);
//用替换的方式,清空file中的值
$("#file_div").html(file_html);
return false;
}
return true;
}
</script>
</body>
</html>