jQuery in Action, 2nd edition*
The moose likes Servlets and the fly likes File Upload problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "File Upload problem" Watch "File Upload problem" New topic
Author

File Upload problem

Kushal Cp
Greenhorn

Joined: Jun 02, 2010
Posts: 2
Hi,
I need to implement File Upload functionality in extjs.I have the client side code as

var fp = new Ext.FormPanel({
renderTo: 'fi-form',
fileUpload: true,
width: 500,
frame: true,
title: 'File Upload Form',
autoHeight: true,
bodyStyle: 'padding: 10px 10px 0 10px;',
labelWidth: 50,
defaults: {
anchor: '95%',
allowBlank: false,
msgTarget: 'side'
},
items: [{
xtype: 'textfield',
fieldLabel: 'Name'
},{
xtype: 'fileuploadfield',
id: 'form-file',
emptyText: 'Select an image',
fieldLabel: 'Photo',
name: 'photo-path',
buttonText: '',
buttonCfg: {
iconCls: 'upload-icon'
}
}],
buttons: [{
text: 'Save',
handler: function(){
if(fp.getForm().isValid()){
fp.getForm().submit({
url: '',
waitMsg: 'Uploading your photo...',
success: function(fp, o){
msg('Success', 'Processed file "'+o.result.file+'" on the server');
}
});
}
}
},{
text: 'Reset',
handler: function(){
fp.getForm().reset();
}
}]
});

In the URL i need to provide alink to the file which uploads the file onto the server. Can anyone provide the server side(servlet) code to implement the functionality ?
Martin Vanyavchich
Ranch Hand

Joined: Sep 16, 2008
Posts: 241
Please use code tags ... I'm guessing, but should this go into a JavaScript forum?



SCJP 6, OCMJD 6, OCPJWSD 6
I no good English.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42061
    
  64
A servlet utilizing the Apache FileUpload library should do the trick.


Ping & DNS - my free Android networking tools app
Kushal Cp
Greenhorn

Joined: Jun 02, 2010
Posts: 2
Ulf Dittmer wrote:A servlet utilizing the Apache FileUpload library should do the trick.


Hi Ulf Dittmer, I tried to use it but wasnt sucessful So,can you please provide the source code..?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

The documentation on their site includes sample code for using the fileupload library.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Lawrence Xu
Greenhorn

Joined: Feb 11, 2004
Posts: 11
please to use upload lib such as lib from apache
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Lawrence Xu wrote:please to use upload lib such as lib from apache


The fileupload library from Apache is what we are discussing.
 
 
subject: File Upload problem