1

ファイルを追加した後、次の 2 つのエラーが発生します。

   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');
                        }

エラーは1つだけです:

        Blocked a frame with origin "http://host:8080" from accessing a frame with origin "http://host". Protocols, domains, and ports must match. 

すべてのファイルのアップロードが成功しました (2 つの例)。

4

2 に答える 2

0

これは実際には、すでに特定されている Extjs のバグです。

http://www.sencha.com/forum/showthread.php?136092-Response-lost-from-upload-Ajax-request-to-iframe-if-document.domain-changed

投稿の回避策を参照してください

于 2014-05-29T14:44:18.813 に答える