upload.js 2.5 KB

1
  1. function uploadInit(){var swfu;var settings={flash_url:"/js/ui/swfupload/Flash/swfupload.swf",upload_url:"/js/ui/swfupload/upload.php",post_params:{PHPSESSID:"11111"},file_size_limit:"100 MB",file_types:"*.mp3;",file_types_description:"选择上传文件",file_upload_limit:-1,file_queue_limit:0,debug:false,button_image_url:"/images/upload_2.jpg",button_width:"55",button_height:"15",button_placeholder_id:"spanButtonPlaceHolder",button_text:'<span id="spanButtonPlaceHolder"></span>',button_text_style:"",button_text_left_padding:12,button_text_top_padding:3,button_action:SWFUpload.BUTTON_ACTION.SELECT_FILE,button_cursor:SWFUpload.CURSOR.HAND,file_queue_error_handler:function(obj){$("#fsUploadProgressLine,#successLine").hide();$("#errorLine").html(obj.name+" 文件大小超出,限制100MB").show()},file_dialog_complete_handler:function(){this.startUpload()},upload_start_handler:function(){$("#successLine,#errorLine").hide();$("#fsUploadProgressLine").show()},upload_progress_handler:function(obj,currSize,allSize){$("#fsUploadProgress").css("width",currSize/allSize*100+"%")},upload_error_handler:function(){$("#fsUploadProgressLine,#successLine").hide();$("#errorLine").html("上传失败!").show()},upload_success_handler:function(obj,responseText){var p=eval("("+responseText+")");if(p.code==200){$("#fsUploadProgressLine,#errorLine").hide();var str='<object type="application/x-shockwave-flash" data="/js/ui/dewplayer/dewplayer-mini.swf?mp3=/js/ui/swfupload/upload/'+p.filename+'" width="160" height="20" id="dewplayer-mini"><param name="wmode" value="transparent" /><param name="movie" value="/js/ui/dewplayer/dewplayer-mini.swf?mp3=/js/ui/swfupload/upload/'+p.filename+'" /></object>';$("#successLine").html(str+"<a href=\"javascript:insertFile('"+p.filename+"')\">插入《"+obj.name+"》</a>").show()}else{$("#fsUploadProgressLine,#successLine").hide();$("#errorLine").html(p.msg).show()}swfu.addPostParam("filename",p.filename);$("#filename").val(p.filename)}};swfu=new SWFUpload(settings)}function insertFile(filename){var str='<object type="application/x-shockwave-flash" class="video" data="/js/ui/dewplayer/dewplayer-mini.swf?mp3=/js/ui/swfupload/upload/'+filename+'" width="160" height="20" id="dewplayer-mini"><param name="wmode" value="transparent" /><param name="movie" value="/js/ui/dewplayer/dewplayer-mini.swf?mp3=/js/ui/swfupload/upload/'+filename+'" /></object>';$("#swfuploadDiv").data("editor").execCommand("insertHtml",str);$("#swfuploadDiv").closeDialog();$("#successLine").html("")}$(function(){uploadInit()});