Example(http://www.sencha.com/deploy/dev/exa...le-upload.html)を
参考にしながら、ファイルをアップロードするページを作成しています。
ところが、コールバック処理(successやfailure)において取得できるはずのresultオブジェクトが、
なぜか参照エラーとなってしまいます。
原因についてお心当たりがあればアドバイスをお願いします。
Code:
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
<title>File Upload</title>
<link rel="stylesheet" type="text/css" href="http://www.sencha.com/deploy/dev/resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css" href="http://www.sencha.com/deploy/dev/examples/shared/examples.css" />
<link rel="stylesheet" type="text/css" href="http://www.sencha.com/deploy/dev/examples/ux/fileuploadfield/css/fileuploadfield.css"/>
<script type="text/javascript" src="http://www.sencha.com/deploy/dev/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="http://www.sencha.com/deploy/dev/ext-all.js"> </script>
<script type="text/javascript" src="http://www.sencha.com/deploy/dev/examples/ux/fileuploadfield/FileUploadField.js"> </script>
<style type="text/css">
.upload-icon {
background: url('http://www.sencha.com/deploy/dev/examples/shared/icons/fam/image_add.png') no-repeat 0 0 !important;
}
</style>
<script type="text/javascript">
Ext.onReady(function () {
// フォーム
var fp = new Ext.FormPanel({
renderTo: 'form1',
fileUpload: true,
width: 300,
frame: true,
title: 'File Upload Form',
bodyStyle: 'padding: 10px 10px 0 10px;',
items: [{
xtype: 'fileuploadfield',
fieldLabel: 'File',
name: 'fName',
buttonText: '',
buttonCfg: { iconCls: 'upload-icon' },
listeners: {
'fileselected': function (btn, v) {
execUpload(btn, v);
}
}
}, {
xtype: 'displayfield',
id: 'dsp',
value: ''
}
]
});
// アップロード
var execUpload = function (btn, v) {
Ext.getCmp('dsp').setValue('アップロード中...');
fp.getForm().submit({
url: 'http://www.sencha.com/deploy/dev/examples/form/file-upload.php',
method: 'POST',
success: function (f, action) {
Ext.getCmp('dsp').setValue('アップロードに成功しました');
var ans = action.result.success; // ここで参照エラーが発生
}
});
};
});
</script>
</head>
<body>
<div id="form1"></div>
</body>
</html>