westdc-zf1/application/default/views/scripts/author/document-upload.phtml

135 lines
4.4 KiB
PHTML
Raw Normal View History

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>数据上传</title>
<link rel="stylesheet" type="text/css" media="screen" href="/css/default.css" />
<script src='/static/js/jquery-1.7.2.min.js' type="text/javascript"></script>
<script type="text/javascript" src="/static/js/uploadify/swfobject.js"></script>
<script type="text/javascript" src="/static/js/uploadify/jquery.uploadify.v2.1.4.min.js"></script>
<script type="text/javascript" src="/js/jquery.colorbox-min.js"></script>
<link href="/css/author.css" media="screen" rel="stylesheet" type="text/css"/>
<link href="/static/js/uploadify/uploadify.css" media="screen" rel="stylesheet" type="text/css" />
<link href="/css/colorbox.css" media="screen" rel="stylesheet" type="text/css" />
</head>
<body>
<!-- 页面内容 -->
<div id="wapper">
<form id='datafiles'>
<?php if(!empty($this->uuid))
{
?>
<input type="hidden" name="uuid" value="<?php echo $this->uuid;?>" />
<p>
<label>数据上传:</label>
<div><input id="file_upload" name="Filedata" type="file" /></div>
<input type="button" class="btn btn-small" onclick="$('#file_upload').uploadifyUpload();" value="上传" />
<div id="datalist"></div>
</p>
文件上传后会自动保存,不需要重复提交
<?php }else{
echo "参数错误!";
}?>
</form>
</div>
<!-- //页面内容 -->
<script>
<?php if(!empty($this->uuid))
{
?>
$(document).ready(function() {
$('#file_upload').uploadify({
'uploader' : '/static/js/uploadify/uploadify.swf',
'scriptData': {'PHPSESSID' : '<?php echo session_id(); ?>','uuid':'<?php echo $this->uuid;?>','submit':'1'},
'script' : '/author/document/ac/upload',
'cancelImg' : '/static/js/uploadify/cancel.png',
'folder' : '/uploads',
'sizeLimit' : 52428800,
'queueSizeLimit' : 10,
'multi' : true,
'auto' : false,
'displayData' : 'speed',
'buttonImg' : '/static/js/uploadify/selectfile.gif',
'onComplete' : function(event, ID, fileObj, response, data) {
var obj = jQuery.parseJSON(response);
if(obj.error=='')
{
html = obj.html;
}
else{html=uploadError(obj.error,obj.attid);}
$('<li/>', {
"id":'uploadedItem_'+obj.attid,
"class":'uploadifyQueueItem',
"html": html
}).appendTo('#datalist');
$('#deletebtn_'+obj.attid).bind('click', function() {
deleteatt(obj.attid);
});
},
'onError' : function (event,ID,fileObj,errorObj) {
alert(errorObj.type + ' Error: ' + errorObj.info);
}
});
});
function Submit(){
$.ajax({
'type':"POST",
'url':'/submit/upload/',
'data':'ac=submit&'+$('#datafiles').serialize(),
'success':function(data){
if (typeof(data)=='object')
{
if(typeof(data.error)!='undefined')
{$.colorbox({'innerWidth':'50%','html':data.error});}
if(typeof(data.deleted)!='undefined')
{$('#list_'+data.deleted).fadeOut("slow",function(){$(this).remove();});}
if(typeof(data.commited)!='undefined')
{$('#changelog').val('');$('#commit_submit').attr('onclick','');}
}
else{
$.colorbox({'innerWidth':'50%','html':'<img src="/images/alert_big_warning.png" /><h4>出现错误,请稍候再试</h4>'});
}
},
'timeout': 30000,
'error': function(){
$.colorbox({'innerWidth':'50%','html':'<img src="/images/alert_big_error.png" /><h4>处理中出现错误,请刷新页面后重试</h4>'});
}
});
}
function deleteatt(attid){
$.ajax({
type:"POST",
url:'/service/delreviewatt/id/'+attid,
data:'',
success:function(html){
$('#uploadedItem_'+attid).remove();
},
beforeSend:function(){
$('#deletebtn_'+attid).html('<img src="/images/11887177066.gif" />');
}
});
}
function uploadError(msg,id){
var html = msg+'<div class="cancel"><a href="javascript:;" id="deletebtn_'+id+'"><img border="0" src="/static/js/uploadify/cancel.png" /></a></div>';
return html;
}
<?php } ?>
$('#wapper').width($('.body').width()-$('#sidebar').width()-20);
</script>
</body>
</html>