S2SH整合ext上传大文件,小文件上传没问题,稍大的文件(>50m)就出错,后台也没抛出异常,前台在firebug显示missing ) in parenthetical错误
部分代码如下
js代码:
form 表单:
enctype:'multipart/form-data',
fileUpload: true,
fieldLabel: '文档对象',
xtype: 'fileuploadfield',
buttonText:'浏 览 ',
id:'form_newAOAttachment_fileUpload',
emptyText: '请选择文件',
name: 'fileUpload',
anchor:'100%',
...
CCAC.MES.form_newAOAttachment.form.submit({
method:'post',
url:'addAOAttachment.action',
success : function(response, action) {
CCAC.MES.win_newAOAttachment.hide();
btn.enable();
Ext.Msg.alert('成功', '新增附件成功!');
},
failure : function(form, action) {
Ext.Msg.alert('失败', '新增附件失败!');
btn.enable();
},
waitMsg : '正在提交数据,稍后...'java代码:
InputStream is = new FileInputStream(fileUpload);
//创建文件
byte[] data = new byte[(int)is.available()];
is.read(data);
is.close();//关闭流
//装换成blob
Blob file = Hibernate.createBlob(data); ;
attachment.setDocumentObject( file);
attachmentService.save(attachment);
this.jsonString = "{success:true}";
} catch (Exception e) {
this.jsonString = "{success:false}";
}
getResponse().setContentType("text/html; charset=utf-8");
try {
getResponse().getWriter().write(this.jsonString);
} catch (IOException e) {
} 配置文件:
<interceptors>
<interceptor name="jsonFileUploadInterceptor" class="com.ccac.mes.projectdata.action.JsonFileUploadInterceptor"/>
<interceptor-stack name="jsonFileUploadStack">
<interceptor-ref name="jsonFileUploadInterceptor">
<!-- 配置允许上传的文件类型,多个用","分隔 -->
<!-- 配置允许上传的文件大小,单位字节 -->
<param name="maximumSize">1024000000000</param>
</interceptor-ref>
<interceptor-ref name="defaultStack" />
</interceptor-stack>
</interceptors>
<action name="addAOAttachment" class="AOAttachmentAction" method="addAOAttachment">
<interceptor-ref name="jsonFileUploadStack" />
<result name="input">pages/commom/error.html </result>
</action>
各位帮帮忙啊!
部分代码如下
js代码:
form 表单:
enctype:'multipart/form-data',
fileUpload: true,
fieldLabel: '文档对象',
xtype: 'fileuploadfield',
buttonText:'浏 览 ',
id:'form_newAOAttachment_fileUpload',
emptyText: '请选择文件',
name: 'fileUpload',
anchor:'100%',
...
CCAC.MES.form_newAOAttachment.form.submit({
method:'post',
url:'addAOAttachment.action',
success : function(response, action) {
CCAC.MES.win_newAOAttachment.hide();
btn.enable();
Ext.Msg.alert('成功', '新增附件成功!');
},
failure : function(form, action) {
Ext.Msg.alert('失败', '新增附件失败!');
btn.enable();
},
waitMsg : '正在提交数据,稍后...'java代码:
InputStream is = new FileInputStream(fileUpload);
//创建文件
byte[] data = new byte[(int)is.available()];
is.read(data);
is.close();//关闭流
//装换成blob
Blob file = Hibernate.createBlob(data); ;
attachment.setDocumentObject( file);
attachmentService.save(attachment);
this.jsonString = "{success:true}";
} catch (Exception e) {
this.jsonString = "{success:false}";
}
getResponse().setContentType("text/html; charset=utf-8");
try {
getResponse().getWriter().write(this.jsonString);
} catch (IOException e) {
} 配置文件:
<interceptors>
<interceptor name="jsonFileUploadInterceptor" class="com.ccac.mes.projectdata.action.JsonFileUploadInterceptor"/>
<interceptor-stack name="jsonFileUploadStack">
<interceptor-ref name="jsonFileUploadInterceptor">
<!-- 配置允许上传的文件类型,多个用","分隔 -->
<!-- 配置允许上传的文件大小,单位字节 -->
<param name="maximumSize">1024000000000</param>
</interceptor-ref>
<interceptor-ref name="defaultStack" />
</interceptor-stack>
</interceptors>
<action name="addAOAttachment" class="AOAttachmentAction" method="addAOAttachment">
<interceptor-ref name="jsonFileUploadStack" />
<result name="input">pages/commom/error.html </result>
</action>
各位帮帮忙啊!
http://blogger.org.cn/blog/more.asp?name=hongrui&id=3747
byte[] data = new byte[(int)is.available()]; byte 类型可取的最大值,即 27-1。
byte[] data = new byte[(int)is.available()]; byte 类型可取的最大值,即 27-1。
byte[] data = new byte[(int)is.available()]; byte 类型可取的最大值,即 27-1。还是谢谢了