简体   繁体   中英

Is it possible to create txt file using only client side ? … but to a specific folder

I read a lot about this topic but they are all created long ago and saying it's not possible . So I'm wondering is it possible to manipulate with the root of the downloads folder , without jeopardizing the clients privacy ?... because clearly that's the main issue of this problem .

Or does anyone have any other idea on how to cross this problem of not storing the files into specified browser download folder ?

Here are a couple of ways to create files using a website:

  1. Create the file virtually and then have the user download the file. You could also create a single zip file with an entire folder structure to create a folder structure in the download folder once it's unzipped.

  2. Use the Filesystem API which has terrible support, I think it's pretty much just Chrome that supports it and it's severely limited. Not recommended.

  3. Use something like Emscripten to have a nicer Filesystem API available. That way you can create the folders and files easily before you, you guessed it, create a zip file that the user downloads. Emscripten has a virtual filesystem that you handle using C++ standard file input/output.

  4. Create an extension for the target browser(s) that the user has to install before you can create files in their filesystem. API's for this is somewhat limited but could be a solution for you since it allows direct editing of files as opposed to first zipping and downloading/unzipping a zip file.

  5. Create your website as a Cordova application and use its filesystem API. Note that this doesn't let your website use the users filesystem, but it allows you to easily distribute your website in the form of an installable app that can then use native tech to interact with the filesystem.

There may be more solutions but these are the ways that came to mind. The reason it's a bit problematic to interact with the filesystem is for obvious security issues that arise when a malicious site could then just create a virus in your filesystem and then request that it gets opened by another program on your computer and if the user then presses accept, BAM, virus infested computer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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