简体   繁体   English

JavaScript-将图片从URL保存到本地计算机的特定路径?

[英]JavaScript - Save image from URL to local machine specific path?

Using jQuery/javascript I am making a personal program for me and my friends to use. 使用jQuery / javascript,我正在为我和我的朋友制作一个个人程序。 I wanted to have a functionality that downloads a file from an external (online) url and then save it to a particular directory relative to my /root folder. 我想拥有一种功能,可以从外部(在线)URL下载文件,然后将其保存到相对于/ root文件夹的特定目录中。

I cannot use this on a server as I just want to run the html file locally - however it may be hosted online in the future. 我不能在服务器上使用它,因为我只想在本地运行html文件-但是将来可能会在线托管。

I'm not worried about security at this current point in time - so is this possible to do? 我现在不担心安全性-这有可能吗?

In Javascript you cannot directly save a file to your root folder or choose the location of where the file is saved. 在Javascript中,您不能直接将文件保存到根文件夹中,也不能选择文件的保存位置。 However with Javascript you can cause the browser to prompt the user to save the file locally. 但是,使用Javascript可以使浏览器提示用户将文件保存在本地。 Take a look at this github project: 看一下这个github项目:

https://github.com/eligrey/FileSaver.js https://github.com/eligrey/FileSaver.js

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

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