html代码:
loadfile.getForm().submit({
url: 'http://host/test/file-upload.php?path='+r.get('dtp'),
waitMsg: 'Сохранение фотографии...',
success: function(loadfile, o){
Ext.Msg.alert('Success', o.result.msg);
}
});
文件上传.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": "Файл не сохранён!"}';
}
?>
我得到错误:
Uncaught TypeError: Cannot read property 'msg' of undefined
如果在 html 中设置:
Ext.Msg.alert('Success', 'Success...');
它的所有工作,但总是成功。