修改了修改附件的方式

This commit is contained in:
Li Jianxuan 2012-06-12 10:01:30 +00:00
parent aba271ee99
commit ce88ae9963
3 changed files with 79 additions and 34 deletions

View File

@ -1267,6 +1267,9 @@ class Admin_DataController extends Zend_Controller_Action
elseif($attupdate)
{
$submit = $this->_getParam('submit');
if(!empty($submit))
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
@ -1301,8 +1304,6 @@ class Admin_DataController extends Zend_Controller_Action
$this->jsonexit($data);
return true;
}
}else{
@unlink($filename);
$data = array("error"=>'附件上传失败:'.$msg['error']);
@ -1314,6 +1315,12 @@ class Admin_DataController extends Zend_Controller_Action
$data = array("error"=>"处理中出现错误".$id);
$this->jsonexit($data);
return true;
}else{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer('attachments-update');
$id = $this->_getParam('attupdate');
$this->view->id = $id;
}
}//附件文件更新

View File

@ -0,0 +1,68 @@
<!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="fileUpdate" method="post">
<p>注:要更新的文件只能选择一个<br />
<ul id="datalist"></ul>
<input id="file_upload" name="Filedata" type="file" />
<input type="button" class="btn btn-small btn-green" onclick="$('#file_upload').uploadifyUpload();" value="更改" />
</p>
</form>
</div>
<!-- //页面内容 -->
<script>
$(document).ready(function() {
$('#file_upload').uploadify({
'uploader' : '/static/js/uploadify/uploadify.swf',
'scriptData': {'PHPSESSID' : '<?php echo session_id(); ?>','submit':'1'},
'script' : '/admin/data/attachments/attupdate/<?php echo $this->id ?>',
'folder' : '/uploads',
'multi' : false,
'auto' : false,
'displayData' : 'speed',
'buttonImg' : '/static/js/uploadify/selectfile.gif',
'onComplete' : function(event, ID, fileObj, response, data) {
var obj = jQuery.parseJSON(response);
var html;
if(obj.error=='')
{html = obj.html;}else{html = obj.error;}
$('<li/>', {
"id":'uploadedItem_'+obj.attid,
"class":'uploadifyQueueItem',
"html": html
}).appendTo('#datalist');
if(obj.ok!=null)
{
Alert('文件修改成功!');
setTimeout("parent.$.fn.colorbox.close();parent.window.location.href=parent.window.location.href;",2000);
}
},
'onError' : function (event,ID,fileObj,errorObj) {
alert(errorObj.type + ' Error: ' + errorObj.info);
}
});
});
function Alert(html){
$.colorbox({'innerWidth':'50%','html':'<h4>'+html+'</h4>'});
}
</script>
</body>
</html>

View File

@ -57,7 +57,7 @@
<td>'.$v['downtimes'].'</td>
<td>'.date('Y-m-d H:i:s',strtotime($v['ts_created'])).'</td>
<td>
<a href="#fileUpdate" class="inline" onclick="update('.$v['id'].')">更新文件</a>
<a href="/admin/data/attachments/attupdate/'.$v['id'].'" class="iframe">更新文件</a>
<a href="javascript:;" onclick="delmdatt('.$v['id'].')">从此元数据中移除</a>
<a href="/service/attach/id/'.$v['id'].'">下载</a>
</td>
@ -94,37 +94,7 @@ function delmdatt(id){
'error': function(){Alert('处理中出现问题,请重试');}
});
}
function update(id){
$('#file_upload').uploadify({
'uploader' : '/static/js/uploadify/uploadify.swf',
'scriptData': {'PHPSESSID' : '<?php echo session_id(); ?>'},
'script' : '/admin/data/attachments/attupdate/'+id,
'folder' : '/uploads',
'multi' : false,
'auto' : false,
'displayData' : 'speed',
'buttonImg' : '/static/js/uploadify/selectfile.gif',
'onComplete' : function(event, ID, fileObj, response, data) {
var obj = jQuery.parseJSON(response);
var html;
if(obj.error=='')
{html = obj.html;}else{html = obj.error;}
$('<li/>', {
"id":'uploadedItem_'+obj.attid,
"class":'uploadifyQueueItem',
"html": html
}).appendTo('#datalist');
if(obj.ok!=null)
{
Alert('文件修改成功!');
setTimeout("window.location.href=window.location.href; ",2000);
}
},
'onError' : function (event,ID,fileObj,errorObj) {
alert(errorObj.type + ' Error: ' + errorObj.info);
}
});
}
$(".iframe").colorbox({iframe:true, width:"50%", height:"50%"});
$(".inline").colorbox({inline:true,'innerWidth':'50%','innerHeight':'50%'});
function Alert(html){
$.colorbox({'innerWidth':'50%','html':'<h4>'+html+'</h4>'});