PDA

View Full Version : Wired Response



gnadirap
6 May 2010, 2:22 AM
Hi all

I Programmed a little fileuploader.

I will post only some code-Expampes, also the PHP Code and the Error-Message i get out of FireBug.

OnUpload JS Code:



function onUpload(){
uploadPanel.buttons[0].disable();
var form = uploadPanel.getForm();
form.submit({
url: addModuleOwner.app.uploadDir,
params:{
upload:'module'
},
waitMsg: lang.module.mod_add.uploadMsg,
success: function(form,o){
console.info(o);
uploadPanel.buttons[0].enable();
moduleStore.reload();
testWizard.setActiveCard("next");
},
failure: function(form,o){
Ext.MessageBox.alert('Failure',o.result.error);
}
});
}


the PHP Code :



if(!is_uploaded_file($file_tmp)){
$core->log->error("could not upload file");
print '{success:false, msg:upload}';
exit(0);
}else {
if(file_exists($upload_dir.$file_name)){
$core->log->error("Could not upload File, File already Exists:".$file_name);
print '{success:false, msg:exists}';
exit(0);
}else {
if (move_uploaded_file($file_tmp,$upload_dir.$file_name)){
$data['type'] = strtoupper($what_upload);
$data['saved_dir'] = $upload_dir;
$data['name'] = $file_name;
$data['file_name'] = $file_name;
$data['upload_date']= date('Y-m-d H:i:s');
$result=$core->db->query_insert('tempUploads',$data);
print "{success:true}";
exit(0);
}else{
$core->log->error("Could not move uploaded File:".$file_name);
print '{success:false,msg:noupload}';
exit(0);
}
}
}



NOW THE FIREBUG Message:
FailureMessage


missing } in XML expression
{success: false,msg: exists} )


Success Message


missing } in XML expression
{success: true} )



Where does this " ) "come frome??? am I blind?

Greeetings and many thanks for your help

Animal
6 May 2010, 5:32 AM
It's the usual thing which is asked here every week by people who have not read the docs.

Last one: http://www.extjs.com/forum/showthread.php?98387-Problem-with-File-Upload&p=464017#post464017

gnadirap
6 May 2010, 9:41 PM
Thanks animal.

I took this code from an example called fileupload for Photos, and there was no header definitions done..

i changed it now to this:



function sendJson($state){
header("content-type: text/html");
print '{success'.$state.'}'
exit(0);
}


But still the same Response

Animal
6 May 2010, 11:20 PM
OK that looks correct (Apart from the capitalization - you could try correcting that), what does the packet look like in the Firebug console?

gnadirap
6 May 2010, 11:30 PM
In the console i don't even get a result.

only firebug prints this:



missing } in XML expression
{success:true} )


in ext-all-debug.jsg(Line: 12436)

Animal
7 May 2010, 12:36 AM
The Net tab will show you the result.

gnadirap
7 May 2010, 12:56 AM
Thx Animal

The Problem was within a class which needed e right setted date_default_timezone_set(). I now added it in the main class and everythink works fine now :-)

thanks to you animal and the net-tab :-)