• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JavaScript Save As Feature?

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 1810
28
jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Saloon Keeper
Posts: 7582
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

J. Kevin Robbins wrote:No exceptions


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.
 
sean cronin
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
J. Kevin Robbins
Bartender
Posts: 1810
28
jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Moores wrote:

J. Kevin Robbins wrote:No exceptions


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.

https://en.wikipedia.org/wiki/JavaScript#Security

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]

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic