添加文件后,我收到两个错误:
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代码:
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代码:
<?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": "Файл не сохранён!"}';
}
?>
如果像这样在 html 中设置(不更改 php 代码):
success: function(loadfile, o){
Ext.Msg.alert('Success', 'Success upload file');
},
failure: function(loadfile, o){
Ext.Msg.alert('Failure', 'Failure upload file');
}
我只有一个错误:
Blocked a frame with origin "http://host:8080" from accessing a frame with origin "http://host". Protocols, domains, and ports must match.
并且所有文件上传成功(举两个例子)。