/* ExtJS code to create a form */
var customerEditMainFormParent = new Ext.FormPanel({
labelAlign: 'top',
header:false,
style: "height: 200px;",
border:false,
renderTo: 'updateCustomer',
id: "customer-form2",
name: "customer-form2",
fileUpload:true,
isUpload: true,
enctype:'multipart/form-data',
url: Ext.SERVER_URL + 'save_file_data',
items: [
{
xtype: 'fileuploadfield',
id: 'filedata',
emptyText: 'Select a document to upload...',
fieldLabel: 'File',
buttonText: 'Browse'
}
]
)};
/* Grails code */
if(params.containsKey("filedata") && bankAccountDetails != null) {
try {
String path = System.getProperty("java.io.tmpdir");
/* Temporary directory */
CommonsMultipartFile uploadFile = request.getFile("filedata");
println uploadFile.getOriginalFilename();
println uploadFile.getContentType();
println uploadFile.getStorageDescription();
uploadFile.transferTo(new File(path+"a.png"));
} catch (Exception ex) {
ex.printStackTrace();
}
}
Sunday, August 11, 2013
File upload using ExtJS and Grails
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment