PDA

View Full Version : Use problem with FileUploadField



tiolebucheron
9 Oct 2009, 11:11 PM
Hello

I try to use FileUploadFile.
I can not get the variables on the file (in the debug console firefox): "tmp_name" "type" "size"
Finally, I try to retrieve the path and extension.


Here you will find the javascript code

function initFormAdminContent() {
var btn_AdmindDGD_Submit = new Ext.Button({
cls: 'x-btn100',
text:'Mise jour',
handler: function(){
if(pan_Admin.getForm().isValid()){
pan_Admin.getForm().submit({
url: '../libs/php/file-upload.php',
waitMsg: 'Uploading your photo...',
success: function(pan_Admin, o){
Ext.Msg.show({title:'Success',msg: o.result.file.tmp_name+'Processed file "'+o.result.file.name+'" on the server', icon: Ext.MessageBox.INFO, buttons: Ext.Msg.OK});
}
});
}
}
});

var file_AdminDGD = new Ext.ux.form.FileUploadField({
hideLabel: true,
buttonOnly: true,
id: 'file_AdminDGD',
name: 'file_AdminDGD',
buttonText: 'Parcourir',
listeners: {
'fileselected': function(fb, v){
var el = Ext.fly('file_AdminDGD_msg');
el.update('<b>Fichier :</b> '+v);
if(!el.isVisible()){
el.slideIn('t', {
duration: .2,
easing: 'easeIn',
callback: function(){
el.highlight();
}
});
}else{
el.highlight();
}
}
}
});

var pan_Admin = new Ext.FormPanel({
title: 'Administration',
fileUpload: true,
frame: true,
items:[{
layout: 'column',
border: false,
items:[{
columnWidth:.5,
layout: 'form',
border:false,
items: [file_AdminDGD]
},{
columnWidth:.5,
layout: 'form',
border:false,
items: [btn_AdmindDGD_Submit]
}]
},{
html:"<div id=\"file_AdminDGD_msg\" style=\"display:none;\"></div>"
}]
});

return pan_Admin;
};Here you will find the php code

<?php
sleep(1);
echo '{success:true, file:'.json_encode($_FILES['file_AdminDGD']).'}';
?>
http://www.imagup.com/pics/1255196461.html
Thank you for your help.
excuse me for my english

Condor
10 Oct 2009, 3:49 AM
You can get the filename by calling fileUploadField.getValue() (also returned by the fileselected event).

Due to security restrictions it's not possible to get the path or the content of the file.

tiolebucheron
12 Oct 2009, 11:51 AM
thank you for your information, this helped me a lot. I managed to run this function. Thank you