PDA

View Full Version : Success function in formPanel is not executed after successfull file upload



zagreberlin
6 Sep 2011, 5:03 PM
Hi people,

i dont know where the problem is. I am trying to implement a file upload.
everything worked fine but now, i dont know why, it redirects me to the php-file which executes the file upload but it remains on the php-file and dont redirect it back to my html file which contains the JS Code.
So the success-method in the formPanel will not be executed but i dont know why. yesterday it was all ok but now it redirects me to the fileuploading.php where i stay and dont go back to my html.
what could be the reason?
Please help!

This is my JS-Code


var panelRightTop = new Ext.FormPanel({
title : 'Upload Files',
width : 360,
renderTo : 'right-top',
standardSubmit : true,
buttonAlign: 'center',
labelWidth : 30,
fileUpload : true,

frame : true,
items: [
{
xtype: 'fileuploadfield',
emptyText: '',
fieldLabel: 'Image 1',
buttonText: 'Select a File',
width : 350,
name: 'img[]'
}, {
xtype: 'fileuploadfield',
emptyText: '',
fieldLabel: 'Image 2',
buttonText: 'Select a File',
width: 350,
name: 'img[]'
}, ],
buttons: [{
text: 'Upload',
handler: function() {
panelRightTop.getForm().submit({
url: 'FileUploading.php',
waitMsg: 'Uploading ....',
success: function(form, o) {
Ext.MessageBox.alert('Success', 'Processed file on the server');
panelRightTop.getForm().reset();
//store.load();
}
});
}
}, {
text: 'Reset',
handler: function() {

Ext.MessageBox.alert('Reset Button');
panelRightTop.getForm().reset();
}
}]
});


Code of the FileUploading.php


$allowedType = array( 'image/jpeg', 'image/pjpeg', 'image/png', 'image/gif', 'image/x-png' );

foreach($_FILES['img']['name'] as $key => $img) { if (in_array($_FILES['img']['type'][$key], $allowedType)) {
move_uploaded_file($_FILES['img']['tmp_name'][$key], 'Uploads/'.$_FILES['img']['name'][$key]); } }