更新了附件上传中的方法
This commit is contained in:
parent
29557c14c1
commit
3acef46848
|
@ -1788,8 +1788,8 @@ class Admin_DataController extends Zend_Controller_Action
|
||||||
|
|
||||||
$id = $this->_getParam('attupdate');
|
$id = $this->_getParam('attupdate');
|
||||||
|
|
||||||
$files=new files();
|
$files=new Files();
|
||||||
$msg = $files -> upload($this->view->config->upload,$_FILES['Filedata'],empty($uuid)?'file':'md');
|
$msg = $files -> upload($_FILES['Filedata'],empty($uuid)?'file/':'md/',true);
|
||||||
|
|
||||||
if(empty($msg['error']))
|
if(empty($msg['error']))
|
||||||
{
|
{
|
||||||
|
@ -1797,7 +1797,7 @@ class Admin_DataController extends Zend_Controller_Action
|
||||||
$filename = $msg['db_path'];
|
$filename = $msg['db_path'];
|
||||||
$filesize = $msg['file_size'];
|
$filesize = $msg['file_size'];
|
||||||
$filedesc = $this->_request->getParam('filedesc');
|
$filedesc = $this->_request->getParam('filedesc');
|
||||||
$filetype = $msg['file_type'];
|
$filetype = 'md';
|
||||||
$realname = $msg['realname'];
|
$realname = $msg['realname'];
|
||||||
|
|
||||||
|
|
||||||
|
@ -2116,8 +2116,8 @@ class Admin_DataController extends Zend_Controller_Action
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
$files=new files();
|
$files=new Files();
|
||||||
$msg = $files -> upload($this->view->config->upload,$_FILES['Filedata'],empty($uuid)?'file':'md');
|
$msg = $files -> upload($_FILES['Filedata'],empty($uuid)?'file/':'md/',true);
|
||||||
|
|
||||||
if(empty($msg['error']))
|
if(empty($msg['error']))
|
||||||
{
|
{
|
||||||
|
@ -2125,7 +2125,7 @@ class Admin_DataController extends Zend_Controller_Action
|
||||||
$filename = $msg['db_path'];
|
$filename = $msg['db_path'];
|
||||||
$filesize = $msg['file_size'];
|
$filesize = $msg['file_size'];
|
||||||
$filedesc = $this->_request->getParam('filedesc');
|
$filedesc = $this->_request->getParam('filedesc');
|
||||||
$filetype = $msg['file_type'];
|
$filetype = 'md';
|
||||||
$realname = $msg['realname'];
|
$realname = $msg['realname'];
|
||||||
|
|
||||||
|
|
||||||
|
@ -2184,10 +2184,6 @@ class Admin_DataController extends Zend_Controller_Action
|
||||||
$rs = $this->db->query($sql);
|
$rs = $this->db->query($sql);
|
||||||
$atts = $rs->fetchAll();
|
$atts = $rs->fetchAll();
|
||||||
|
|
||||||
foreach($atts as $k=>$v)
|
|
||||||
{
|
|
||||||
$atts[$k]['html']= $v['realname'].'['. round($v['filesize']/1024,2) .' kb]<input type="hidden" name="atts[]" value="'.$v['id'].'" /><div class="cancel"><a href="javascript:;" id="deletebtn_'.$v['id'].'"><img border="0" src="/static/js/uploadify/cancel.png" /></a></div>';
|
|
||||||
}
|
|
||||||
echo Zend_Json::encode($atts);
|
echo Zend_Json::encode($atts);
|
||||||
exit();
|
exit();
|
||||||
}else
|
}else
|
||||||
|
|
|
@ -7,12 +7,7 @@
|
||||||
$this->breadcrumb('<a href="/admin">后台首页</a>');
|
$this->breadcrumb('<a href="/admin">后台首页</a>');
|
||||||
$this->breadcrumb('数据管理');
|
$this->breadcrumb('数据管理');
|
||||||
$this->breadcrumb()->setSeparator(' > ');
|
$this->breadcrumb()->setSeparator(' > ');
|
||||||
$this->headLink()->appendStylesheet('/static/js/uploadify/uploadify.css');
|
$this->theme->AppendPlus($this,"uploadify");
|
||||||
$this->headScript()->appendFile('/static/js/jquery-1.7.2.min.js');
|
|
||||||
$this->headScript()->appendFile('/js/jquery.colorbox-min.js');
|
|
||||||
$this->headLink()->appendStylesheet('/css/colorbox.css');
|
|
||||||
$this->headScript()->appendFile('/static/js/uploadify/swfobject.js');
|
|
||||||
$this->headScript()->appendFile('/static/js/uploadify/jquery.uploadify.v2.1.4.min.js');
|
|
||||||
?>
|
?>
|
||||||
<div id="leftPanel">
|
<div id="leftPanel">
|
||||||
<?= $this->partial('data/left.phtml'); ?>
|
<?= $this->partial('data/left.phtml'); ?>
|
||||||
|
@ -21,7 +16,7 @@
|
||||||
|
|
||||||
<div class="ctrlplan">
|
<div class="ctrlplan">
|
||||||
<a href="/admin/data/md/att/1/uuid/<?php echo $this->uuid;?>">返回元数据附件列表</a>
|
<a href="/admin/data/md/att/1/uuid/<?php echo $this->uuid;?>">返回元数据附件列表</a>
|
||||||
<a href="/data/<?php echo $this->uuid; ?>">查看元数据</a>
|
<a href="/data/<?php echo $this->uuid; ?>">查看元数据</a>
|
||||||
<a href="/admin/data/attachments/">返回附件管理</a>
|
<a href="/admin/data/attachments/">返回附件管理</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -30,7 +25,8 @@
|
||||||
<input type="hidden" name="submit" value="1" />
|
<input type="hidden" name="submit" value="1" />
|
||||||
|
|
||||||
<p>注:可选择多个文件<br />
|
<p>注:可选择多个文件<br />
|
||||||
<ul id="datalist"></ul>
|
<div id="datalist">
|
||||||
|
</div>
|
||||||
<input id="file_upload" name="Filedata" type="file" />
|
<input id="file_upload" name="Filedata" type="file" />
|
||||||
<input type="button" class="btn btn-small" onclick="$('#file_upload').uploadifyUpload();" value="上传" />
|
<input type="button" class="btn btn-small" onclick="$('#file_upload').uploadifyUpload();" value="上传" />
|
||||||
</p>
|
</p>
|
||||||
|
@ -38,65 +34,79 @@
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
var _this = {
|
||||||
$('#file_upload').uploadify({
|
SessionID : '<?php echo session_id(); ?>'
|
||||||
'uploader' : '/static/js/uploadify/uploadify.swf',
|
};
|
||||||
'scriptData': {'PHPSESSID' : '<?php echo session_id(); ?>'},
|
var uploader;
|
||||||
'script' : '/admin/data/upload/<?php if(!empty($this->uuid)) echo "uuid/".$this->uuid; ?>',
|
var param;
|
||||||
'cancelImg' : '/static/js/uploadify/cancel.png',
|
param = {
|
||||||
'folder' : '/uploads',
|
"PHPSESSID" : _this.SessionID,
|
||||||
'multi' : true,
|
"multi" : 'yes'
|
||||||
'auto' : false,
|
};
|
||||||
'displayData' : 'speed',
|
$(function() {
|
||||||
'buttonImg' : '/static/js/uploadify/selectfile.gif',
|
$('#file_upload').uploadify({
|
||||||
'onComplete' : function(event, ID, fileObj, response, data) {
|
'swf' : '/js/lib/uploadify/uploadify.swf',
|
||||||
var obj = jQuery.parseJSON(response);
|
'uploader' : '/admin/data/upload/<?php if(!empty($this->uuid)) echo "uuid/".$this->uuid; ?>',
|
||||||
var html;
|
'multi' : true,
|
||||||
if(obj.error=='')
|
'auto' : true,
|
||||||
{html = obj.html;}else{html = obj.error;}
|
'fileTypeExts' : '*',
|
||||||
$('<li/>', {
|
'onUploadSuccess' : function(file, data, response) {
|
||||||
"id":'uploadedItem_'+obj.attid,
|
upload.onsuccess(file, data, response);
|
||||||
"class":'uploadifyQueueItem',
|
},
|
||||||
"html": html
|
'onUploadStart' : function(file) {
|
||||||
}).appendTo('#datalist');
|
$('#file_upload').uploadify('settings','formData',param);
|
||||||
$('#deletebtn_'+obj.attid).bind('click', function() {
|
}
|
||||||
deleteatt(obj.attid);
|
});
|
||||||
});
|
});
|
||||||
},
|
var upload = {
|
||||||
'onError' : function (event,ID,fileObj,errorObj) {
|
onsuccess : function(file, data, response){
|
||||||
alert(errorObj.type + ' Error: ' + errorObj.info);
|
_data = $.parseJSON(data);
|
||||||
}
|
if(!$.isEmptyObject(_data.error))
|
||||||
});
|
{
|
||||||
function deleteatt(id){
|
alert(_data.error);
|
||||||
$.ajax({
|
}else{
|
||||||
'type': "POST",
|
$('#datalist').append(upload.makeFileHtml(_data));
|
||||||
'url': "/admin/data/attachments/",
|
|
||||||
'data': 'uuid=<?php echo $this->uuid?>&mdattdel='+id,
|
|
||||||
'success': function(data){
|
|
||||||
if(data==null){Alert('遇到错误,请重试');return false;}
|
|
||||||
if(data.error!=null){Alert(data.error);return false;}
|
|
||||||
if(data.status==1){$('#uploadedItem_'+id).fadeOut("slow");}
|
|
||||||
},
|
|
||||||
'beforeSend':function(){},
|
|
||||||
'complete':function(){},
|
|
||||||
'timeout': 20000,
|
|
||||||
'dataType': 'json',
|
|
||||||
'error': function(){Alert('处理中出现问题,请重试');}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
makeFileHtml : function(data){
|
||||||
|
return '<div class="alert alert-success">'
|
||||||
|
+ '<button type="button" class="close" data-dismiss="alert" onclick="upload.deleteFile('+data.id+')"><i class="icon-trash icon-white"></i></button>'
|
||||||
|
+ data.realname
|
||||||
|
+'<input type="hidden" name="attid" value="'+data.id+'"></input>'
|
||||||
|
+'</div>';
|
||||||
|
},
|
||||||
|
deleteFile : function(id){
|
||||||
|
$.ajax({
|
||||||
|
'type':"POST",
|
||||||
|
'url':'/admin/data/attachments/',
|
||||||
|
'data':'uuid=<?php echo $this->uuid?>&mdattdel='+id,
|
||||||
|
'success':function(data){
|
||||||
|
if(typeof(data) == 'undefined')
|
||||||
|
{
|
||||||
|
alert("数据源错误,请联系管理员");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$.isEmptyObject(data.error))
|
||||||
|
{
|
||||||
|
alert(data.error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'timeout': 30000,
|
||||||
|
'error': function(){
|
||||||
|
alert('附件删除出错');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
$.getJSON("/admin/data/getatts/uuid/<?php echo $this->uuid;?>", function(data) {
|
$.getJSON("/admin/data/getatts/uuid/<?php echo $this->uuid;?>", function(data) {
|
||||||
if(data)
|
if(data)
|
||||||
{
|
{
|
||||||
$.each(data, function(key, val) {
|
$.each(data, function(key, val) {
|
||||||
$('<li/>', {
|
$('#datalist').append(upload.makeFileHtml(val));
|
||||||
"id":'uploadedItem_'+val['id'],
|
|
||||||
"class":'uploadifyQueueItem',
|
|
||||||
"html": val['html']
|
|
||||||
}).appendTo('#datalist');
|
|
||||||
$('#deletebtn_'+val['id']).bind('click', function() {
|
|
||||||
deleteatt(val['id']);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue