PDA

View Full Version : fileupload submit issue



cpascaud
18 Jun 2010, 12:57 AM
Hello everybody,

Thanks to help people like me.

I have a problem with my form's submit.
Here is my code



var WrapperTitleEdit = new Ext.form.TextField({
fieldLabel: 'Titre',
id:'idtitle',
name: 'title',
width: 100,
allowBlank: true,
value: dataItemGrid.title
});

var WrapperDescriptionEdit = new Ext.form.TextField({
fieldLabel: 'Description',
id:'iddescription',
name: 'description',
width: 100,
allowBlank: true,
//blankText: 'Une description est requise',
value: dataItemGrid.description
});

var WrapperLinkEdit = new Ext.form.ComboBox({
store: webpageStore,
displayField:'name',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'Entrez ou sélectionnez un lien',
selectOnFocus:true,
id: 'WrapperLinkEdit',
name: 'link',
allowBlank: false,
blankText: 'Un lien est requis',
editable:false,
maxLength: 150,
value: dataItemGrid.link,
fieldLabel: 'page'
});

var WrapperUploadField = new Ext.ux.form.FileUploadField({
id: 'idphoto',
fieldLabel: 'Photo',
width:350,
value:dataItemGrid.photo,
allowBlank: false,
blankText: 'Une image est requise',
name: 'photo-path',
readOnly : true,
regex: /\.(((j|J)(p|P)(g|G))|((g|G)(i|I)(f|F))|((p|P)(n|N)(g|G))|((j|J)(p|P)(e|E)(g|G)))$/,
regexText: "L'image doit être de type '.jpg' '.jpeg' '.png' ou '.gif' ",
buttonText: 'Parcourir'
});

var editWrapperFormPanel = new Ext.form.FormPanel({
autoHeight: true,
id: 'WrapperPanelEdit',
fileUpload: true,
bodyStyle: 'padding:5px 5px 5px 5px',
labelWidth: 85,
defaults: {
anchor: '97%',
msgTarget: 'side'
},
items: [WrapperTitleEdit,WrapperDescriptionEdit,WrapperLinkEdit,WrapperUploadField]
});

var editWrapperWindow = new Ext.Window({
layout: 'fit',
id: 'editWrapperWindow',
width: 350,
height: 300,
resizable: false,
fileUpload: true,
closeAction: 'close',
plain: true,
iconCls: 'icon-slider',
title: "Edition de la feuille",
items: [editWrapperFormPanel],

buttons: [
{
text: 'Ok',
handler: function(){
if(editWrapperFormPanel.getForm().isValid()){
editWrapperFormPanel.form.submit ({
url: Ext.get('baseUrl').getValue()+'wrapper/update',
method : 'POST',
waitMsg: 'Sauvegarde en cours...',
params: {
id: dataItemGrid.wrapper_id,
slider_id: idSlider
},
success: function(form, action){
// Dans le cas d'un update on va récupérer la sélection qu'on avait faite après le reload pour que l'utilisateur voit son nouvel emplacement.
var idWrapperTemp = dataItemGrid.wrapper_id;
var nbl = -1;
var deb =0;
var estUpdate = true;

Ext.StoreMgr.lookup('WrapperStore').on('load', function(store, rec, opt)
{
if (estUpdate)
{
nbl = Ext.StoreMgr.lookup('WrapperStore').find('wrapper_id',idWrapperTemp);
if (nbl ===-1)
{
deb = deb+10;
Ext.StoreMgr.lookup('WrapperStore').reload({params: {start: deb, limit: 7}});
}
else
{
estUpdate = false;
WrapperGrid.getSelectionModel().selectRow(nbl);
}
}
});

Ext.StoreMgr.lookup('WrapperStore').reload({params: {start: 0, limit: 7}});
},
failure: function(form, action){
var response = Ext.util.JSON.decode(action.response.responseText);
Ext.Msg.show({
title:'Error',
msg: response.msg,
buttons: Ext.Msg.OK,
animEl: 'elId',
icon: Ext.MessageBox.ERROR
});
}
});
editWrapperWindow.close();
}
}
}, {
text: 'Annuler',
handler: function(){
editWrapperWindow.close();
}
}]
});



Form post only slider_id and id.
I don't understand where is my problem.
I ll try to pass my data in params but I don't know how i could pass a file in params.

Could you help me please.

Thanks a lot.

CP.

PS: Excuse my english