日期:2014-05-16 浏览次数:20404 次
<!--当然,这里的路径要根据你自己放置的UploadDialog.js的路径来确定--> <script type="text/javascript" src="${webRoot}/scriptLib/ext-3.2.1/Ext.ux.UploadDialog/UploadDialog/UploadDialog.js"></script> <link rel="stylesheet" type="text/css" href="${webRoot}/ext-3.2.1/Ext.ux.UploadDialog/css/Ext.ux.UploadDialog.css"/>
function btn_show(){ var subject = Ext.getCmp('subjectId').getValue(); var role = Ext.getCmp('roleId').getValue(); var publicSound = Ext.getCmp('publicSoundId').getValue(); if(subject==""||role==""){ Ext.MessageBox.alert('提示信息', '请先选择音频科目和角色'); }else{ var dialog = new Ext.ux.UploadDialog.Dialog({ autoCreate : true, minWidth : 450, minHeight : 300, fileSize : 10*1024*1024, title : '文件上传', //是否自动上传 permitted_extensions: ['MP3','mp3','MP4','mp4','WMA','wma'], //允许上传的文件的类型,区分大小写 closable : true, collapsible : false, draggable : true, proxyDrag : true, resizable : true, constraintoviewport : true, modal : true, reset_on_hide : false, allow_close_on_upload: true, url : 'uploadAudioHandelAction.action', base_params :{ subjectID : subject, roleID : role, publicSound : publicSound, userName : userName } }); dialog.show('show-button'); dialog.on('uploadsuccess',onUploadSuccess);//定义上传前的回调函数 dialog.on('uploaderror',onUploadFailed); //定义上传出错回调函数 dialog.on('fileadd',onFileAdd);//定义添加文件时验证文件的函数 dialog.on('uploadcomplete',onUploadComplete);//定义所有文件上传完成回调函数 } };
package com.dfsoft.lion.process.demo.control.model.dismodel.audio; import java.io.File; import java.util.Date; import com.dfsoft.lion.commons.EagleBaseAction; import com.dfsoft.lion.domain.demo.measurement.entity.Audio; import com.dfsoft.lion.domain.demo.measurement.entity.AudioSubjectInfo; import com.dfsoft.lion.domain.demo.measurement.entity.Role; import com.dfsoft.lion.domain.demo.measurement.entity.Users; import com.dfsoft.lion.process.demo.process.model.dismodel.AudioProcess; import com.dfsoft.lion.process.demo.process.model.dismodel.AudioSubjectInfoProcess; import com.dfsoft.lion.process.demo.process.model.dismodel.RoleProcess; import com.dfsoft.lion.process.demo.process.model.dismodel.UsersProcess; import org.apache.commons.io.FileUtils; import javax.servlet.http.HttpServletResponse; import org.apache.struts2.ServletActionContext; /** * @描述:上传音频处理Action * @author lichenglin * */ public class UploadAudioHandelAction extends EagleBaseAction { /** * */ private static final long serialVersionUID = 7716496253903888292L; private Long subjectID ;//科目ID private Long roleID ;// 角色ID private int publicSound; private String userName ; private String filesPath; //接收文件信息 private File[] files; private String[] filesFileName; private String[] filesContentType; transient private AudioProcess audioProcess; transient private RoleProcess roleProcess; transient private AudioSubjectInfoProcess audioSubjectInfoProcess; transient private UsersProcess usersProcess; transient private GetPath getPath; public String execute() throws Exception{ Audio audio = new Audio() ; Users users = this.usersProcess.getUserByName("userName", userName); AudioSubjectInfo audioSubjectInfo = new AudioSubjectInfo(); HttpServletResponse response = ServletActionContext.getResponse(); respo