首页 > 解决方案 > JSZip 错误:文件路径的 Ajax 错误:404 Not Found

问题描述

当我部署并尝试下载时,它说找不到文件

  Error: Ajax error for /Areas/Client/UploadedFiles/2327/Driveshaft.dwg : 404 Not Found

Failed to load resource: the server responded with a status of 404 (Not Found)

当我上传 jpq 或 pdf 时,它工作正常,但 .dwg 文件出错

该文件存在,它说找不到。可能是因为 .dwg 格式。

function zipFiles(file_paths, zipFileName, id) {
var zip = new JSZip();
var count = 0;   
file_paths.forEach(function (url) {
    JSZipUtils.getBinaryContent(url, function (err, data) {
        if (err) {
            //throw err;
            showNotification(err);
        }
        count++;
        if (data != null) {
            zip.file(url, data, { binary: true });

            if (count == file_paths.length) {
                debugger
                zip.folder('' + uploadedDirectory+'' + id+'/')
                    .generateAsync({ type: 'blob' }).then(function (content) {
                        debugger

                        saveAs(content, zipFileName);
                    });
            }
        }
    });
});

}

错误:文件路径的 Ajax 错误:404 Not Found

标签: jszipfilesaver.js

解决方案


如果您无法直接在 Web 浏览器中打开文件,则可能是服务器端配置“错误”。Dwg 是一种不常见的 mimetype,因此默认情况下您的 Web 服务器上可能未启用它。如果您的主机是 iis 服务器,请参阅ERROR 404.3 Not Found for JSON 文件以添加新的 mimetype。对于 dwg,我认为它是“image/vnd.dwg”,但我不确定 100%。


推荐阅读