After added file i get two errors:
Blocked a frame with origin "http://host:8080" from accessing a frame with origin "http://host". Protocols, domains, and ports must match. ext-all.js:3922
Uncaught SyntaxError: Unexpected token )
html code:
buttons: [{
text: 'Save',
handler: function(){
if(loadfile.getForm().isValid()){
loadfile.getForm().submit({
url: 'http://host/test/file-upload.php?path='+r.get('dtp'),
waitMsg: 'Сохранение фотографии...',
success: function(loadfile, o){
var data = Ext.decode(o.response.responseText);
Ext.Msg.alert('Success', data.msg);
},
failure: function(loadfile, o){
var data = Ext.decode(o.response.responseText);
Ext.Msg.alert('Failure', data.msg);
}
});
}
}
},{
text: 'Reset',
handler: function(){
loadfile.getForm().reset();
}
}]
php code:
<?php
$uploaddir = '/var/lib/tomcat6/webapps/test/upload/'.$_GET["path"];
if (!is_dir($uploaddir))
{
mkdir($uploaddir, 0777);
}
$uploaddir.='/';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploaddir.$_FILES['userfile']['name']))
{
echo '("success": true, "msg": "Файл успешно сохранён.")';
} else {
echo '{"success": false, "msg": "Файл не сохранён!"}';
}
?>
If set in html like this(without changed php code):
success: function(loadfile, o){
Ext.Msg.alert('Success', 'Success upload file');
},
failure: function(loadfile, o){
Ext.Msg.alert('Failure', 'Failure upload file');
}
i get only one error:
Blocked a frame with origin "http://host:8080" from accessing a frame with origin "http://host". Protocols, domains, and ports must match.
and all files uploading successful(for two examples).