Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 文件下载-ExtJs 4.2.3_Javascript_Extjs_Download - Fatal编程技术网

Javascript 文件下载-ExtJs 4.2.3

Javascript 文件下载-ExtJs 4.2.3,javascript,extjs,download,Javascript,Extjs,Download,我使用的是ExtJS4.2.3。 在我的web应用程序中,我需要下载文件。 为了做到这一点,我使用了一个在post中定义的“FileDownloader”组件 代码是: Ext.define('myApp.FileDownload', { extend: 'Ext.Component', alias: 'widget.FileDownloader', autoEl: { tag: 'iframe', cls: 'x-hidden', src

我使用的是ExtJS4.2.3。 在我的web应用程序中,我需要下载文件。 为了做到这一点,我使用了一个在post中定义的“FileDownloader”组件

代码是:

Ext.define('myApp.FileDownload', {
   extend: 'Ext.Component',
   alias: 'widget.FileDownloader',
   autoEl: {
      tag: 'iframe',
      cls: 'x-hidden',
      src: Ext.SSL_SECURE_URL
},

load: function(config) {

    var e = this.getEl();
    e.dom.src = config.url +
        (config.params ? '?' + Ext.Object.toQueryString(config.params) : '');

        console.log('in FileDownloader - src: ' + e.dom.src);

        e.dom.onLoad = function() {
        if(e.dom.contentDocument.body.childNodes[0].wholeText == '404') {
            Ext.Msg.show({ 
                title: 'Attachment missing',
                msg: 'File cannot be found on the server !',
                buttons: Ext.Msg.OK,
                icon: Ext.MessageBox.ERROR
            });
        };
    };

}
}))

我称之为代码:

downloader.load({
   url: src
});
其中src是文件的完整路径


如果我下载Word、Excel、PDF文件,它工作得很好,文件引用在浏览器的下载栏中是可视化的,但对于其他数据类型(例如.txt、.jpg),它什么都不做。

我认为这不是Extjs或js的问题,这是服务器的响应。看到这个了吗