PDA

View Full Version : File Upload problem



sseema
8 Mar 2009, 8:43 PM
Hi,

I am created one form in that i put one field as file for upload a file..
For uploading a file we have to pass parameter that server can understands that it is file.


Can any one please tell me what is that parameter?
where can I add that one?

My code....

uploadFile = new Ext.form.TextField({
fieldLabel: 'File',
name: 'import',
id:'import',
inputType: 'file',
readonly:true,
width: 200
});

uploadform = new Ext.form.FormPanel({
id:'upload_form',
frame:'true',
labelWidth:60,
bodyStyle: 'padding: 10px 10px 0 10px;',
//bodyStyle:'padding:10px 5px 25px 15px;',
width: 500,
autoScroll:true,
labelAlign:'center',
fileUpload : true,

items:[
uploadFile]
}):

I appreciate any help...


Thank You...

veereshsh
8 Mar 2009, 9:47 PM
chek for the content type is multipart or not..if its file upload field its contenttype will be multipart
and after ward get the attributes of the file upload field using
ServletFileUpload fileUpload = new ServletFileUpload(new DiskFileItemFactory());
items = fileUpload.parseRequest(request);
Iterator iter=items.iterator();
FileItem item = (FileItem)iter.next();
and you item.getFieldName();item.get();item.getContentType() will help you

sseema
8 Mar 2009, 10:07 PM
Hi, Thanks for your reply..

How to set conetent type multipart to a field.

Here I am sending value of a upload field to server.

Thank You.

shibubh
8 Mar 2009, 10:15 PM
check this


http://www.extjs.com/deploy/dev/examples/form/file-upload.html

and then



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',
buttonCfg: {
text: '',
iconCls: 'upload-icon'
}
}],
buttons: [{
text: 'Save',
handler: function() {
if (fp.getForm().isValid()) {
fp.getForm().submit({
url: 'file-upload.php',
params: "IsFile=true",
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();
}
}]
});