简体   繁体   English

将文件保存在angular.js中的特定文件夹中

[英]To save file in specific folder in angular.js

 if (exportdata != null) { var blob = new Blob([s2ab(exportdata.filedata)], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" }); //saveAs provided by FileSaver.js saveAs(blob, exportdata.filename); framework.displayAlert('ERRORS.SUCCESS', 'Data downloaded successfully'); } else { framework.displayAlert('ERRORS.ERROR', data.error); } function s2ab(s) { var buf = new ArrayBuffer(s.length); var view = new Uint8Array(buf); for (var i = 0; i != s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF; return buf; } 

In saveAs() I have given the file type and filename. saveAs()我给出了文件类型和文件名。 It will save with the given file name in the downloads folder. 它将使用给定的文件名保存在downloads文件夹中。 But I want to save it in D://Reports/sample/ this path. 但我想将其保存在D://Reports/sample/此路径中。 Is there any options to achieve this? 有没有实现这一目标的选择?

This cannot be done. 无法做到这一点。 The browsers for obvious security reasons doesn't allow files to be saved to specific locations only by the user (by right click -> save as) it won't allow you to set the destination folder. 出于明显的安全原因,浏览器不允许仅由用户将文件保存到特定位置(通过右键单击->另存为),不允许您设置目标文件夹。

Otherwise imagine that any site would be able to save files where ever it wants on your computer. 否则,请想象任何站点都将能够在计算机上的任何位置保存文件。

If you need to save Blobs to specific locations you will have to do it on the server side. 如果需要将Blob保存到特定位置,则必须在服务器端进行操作。 Upload the Blob to your server and then you'll be able to save it where ever you want to. 将Blob上传到您的服务器,然后就可以将其保存到任何位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM