Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Jan 2004
    Location
    undefine
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to open a save file dialog box in javascript

    undefine

  • #2
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    you can't. you can only do it JScript. but even if it was cross-browser I wouldn't show you how ... you could be up to no good!
    *keep it simple (TM)

  • #3
    New Coder
    Join Date
    Dec 2004
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    try this: (ie only)

    <button onclick="javascript:document.execCommand('SaveAs','1','fileName.txt')">Click to save</Button>

  • #4
    Smokes a Lot
    Join Date
    Jul 2003
    Location
    CA, USA
    Posts
    1,594
    Thanks
    5
    Thanked 20 Times in 20 Posts
    If you just want to have the user save a file, just make a link to the file on your server, the browser will take care of everything else. If you just want to allow the user to browse the file system. You can use:

    <input type="file">

    To retrieve a file path from the user.

    Basscyst

    PS. J-bot I understand where you are coming from, but there are plenty of resources on this stuff, all over.
    Helping to build a bigger box. - Adam Matthews

  • #5
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Basscyst
    PS. J-bot I understand where you are coming from, but there are plenty of resources on this stuff, all over.
    i know, that's why I don't see the point us adding to it ... for certain exploits anyway.
    *keep it simple (TM)

  • #6
    New to the CF scene
    Join Date
    Jul 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    JavaScript+HTML+CSS on client side allows you initiate File Dialog!

    JavaScript+HTML+CSS on client side allows you initiate File Dialog!
    JavaScript (together with HTML and CSS) strictly on client side (without server support) allows you initiate File Dialog and store results in the specified object as shown here:
    http://www.ardentedge.com/pr_fd.htm
    and
    http://www.ardentedge.com/pr_WidgetB...FileDialog.htm

    When user gets the file name from File Dialog, s/he can do what he wants: open, upload, save appropriate file...

  • #7
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,907
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    Quote Originally Posted by galatoms View Post
    JavaScript+HTML+CSS on client side allows you initiate File Dialog!
    JavaScript (together with HTML and CSS) strictly on client side (without server support) allows you initiate File Dialog and store results in the specified object as shown here:
    http://www.ardentedge.com/pr_fd.htm
    and
    http://www.ardentedge.com/pr_WidgetB...FileDialog.htm

    When user gets the file name from File Dialog, s/he can do what he wants: open, upload, save appropriate file...
    Yes, but only on the client computer!!!!
    To handle a file upload to the server, a server-side process (cgi script) must be running that can handle multipart/form-data submissions.
    Last edited by Philip M; 07-15-2008 at 09:29 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •