Is it possible to make a save as feature with plain JavaScript or jQuery? i.e juts looking to create a straight forward dialogue, where a user can save the file to a particular location. In my
case I don't care about file types as I will only be saving as XML. I currently have it working with a download feature and a popup box to name the file being downloaded, but it would
be nice if the user could save to their own personal location. This project is for my work placement and they just want me using plain JavaScript.
Now I have been doing a lot of reading up in this and people are saying it can't be done, but a lot of those posts are a few years old now and was thinking that with HTML5 their
might be something. I did come across the FileSaver interface of the File API but when I used demo's people had up, it was basically doing the same this as the download
feature I'm currently using.
Thanks in advance.
Life is a soundtrack, Play it loud! https://soundcloud.com/sean-cronin
Nope. The naysayers are correct; it can't be done. By design, JavaScript cannot access the local file system. Period. No exceptions. Just imagine the security hole that would create.
"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." -- Ted Nelson
I wouldn't put it in quite such absolute terms. That's what the File API sean mentioned is all about, after all. I don't think it addresses the save dialog issue, though.
Is their any way at all of doing it with JavaScript then? Like if I asked my manager could I some other JavaScript library or framework would it be possible or will JavaScript always
leave that security hole?
Life is a soundtrack, Play it loud! https://soundcloud.com/sean-cronin
I wouldn't put it in quite such absolute terms. That's what the File API sean mentioned is all about, after all. I don't think it addresses the save dialog issue, though.
That's very interesting. I've never seen that library before. Still seems like a security issue to me.
Web browsers are capable of running JavaScript outside the sandbox, with the privileges necessary to, for example, create or delete files. Of course, such privileges aren't meant to be granted to code from the Web.
Incorrectly granting privileges to JavaScript from the Web has played a role in vulnerabilities in both Internet Explorer[75] and Firefox.[76] In Windows XP Service Pack 2, Microsoft demoted JScript's privileges in Internet Explorer.[77]
Microsoft Windows allows JavaScript source files on a computer's hard drive to be launched as general-purpose, non-sandboxed programs (see: Windows Script Host). This makes JavaScript (like VBScript) a theoretically viable vector for a Trojan horse, although JavaScript Trojan horses are uncommon in practice.[78]
"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." -- Ted Nelson
Don't get me started about those stupid light bulbs.