PDA

View Full Version : problem with upload a file



andryi
24 Aug 2009, 8:11 AM
Hi all, I've got a problem, with the enctype, well, I supposed:

here is my code


var top2 = new Ext.FormPanel({
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(top2.getForm().isValid()){
top2.getForm().submit({
url:'JSP/upload.jsp',
method: 'POST',
enctype: 'multipart/form-data',
waitMsg: 'Uploading your video...',
success: function(top2, o){
alert("you did it");
},
failure: function(top2,o){
msg('Error','wrong);
}
});
}
}
},{
text: 'Reset',
handler: function(){
top2.getForm().reset();
}
}]
});

top2.render(document.body);
So when I run the app, the alert appear, but when I check my disk, nothing happened, not save the file

jarlau
24 Aug 2009, 6:24 PM
http://extjs.com/deploy/dev/docs/?class=Ext.form.BasicForm&member=fileUpload

andryi
25 Aug 2009, 7:05 AM
well I changed a little my code, but still not works



buttons: [{
text: 'Save',
handler: function(){
if(top2.getForm().isValid()){
top2.getForm().submit({
autoCreate: {
tag: 'form',
action: 'JSP/upload2.jsp',
method: 'POST',
enctype: 'multipart/form-data',
name: 'upload-form'
}
})
}
}
}]

jarlau
25 Aug 2009, 7:35 AM
try


top2.getForm().submit({
url:'JSP/upload.jsp',
method: 'POST',
fileUpload: true,
waitMsg: 'Uploading your video...',
success: function(top2, o){
alert("you did it");
},
failure: function(top2,o){
msg('Error','wrong);
}
});