MultiPartRequestWrapper multipartRequest = (MultiPartRequestWrapper) getRequest();
File[] file = multipartRequest.getFiles("file");// 获得文件
String[] filenames = multipartRequest.getFileNames("file");
for (int i = 0; i < filenames.length; i++){
File f1 = file[i];
byte[] fileArray = org.springframework.util.FileCopyUtils.copyToByteArray(f1);
JlsPhotos jlsPhotos =new JlsPhotos();
jlsPhotos.setPhoto(Hibernate.createBlob(fileArray));
jlsPhotosManager.save(jlsPhotos);
}
ext前台代码
Ext.apply(this,{
fileUpload: true,
items:[{
{
xtype : 'textfield',
fieldLabel: '选择正面照片',
name : 'file',
'300',
inputType: 'file'
}