SaveAs Command

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Repairman2003

    SaveAs Command

    I'm using <a href="javascrip t:document.exec Command('SaveAs ', true,
    'folder/file.ext')but it always returns false no matter what because
    of the fact that I'm trying to save a file that isn't in the same
    folder on the server. Can execCommand() not take an argument for a
    file that is locatied in a different folder? How can this be done?
    And if I can prepopulate a target location on the user's machine that
    would be the best solution, (eg. c:\some folder\). I don't think that
    is possible with javascript because of security, but I may be wrong.

    window.location () will take in a folder, so I can always fall back on
    that.

    Thanks,

    Matthew
  • Thomas 'PointedEars' Lahn

    #2
    Re: SaveAs Command

    Repairman2003 wrote:
    I'm using <a href="javascrip t:document.exec Command('SaveAs ', true,
    'folder/file.ext')but it always returns false no matter what because
    of the fact that I'm trying to save a file that isn't in the same
    folder on the server.
    You are very confused. First, the SaveAs command saves to the client, so
    the location of the server-side resource does not matter. Second, your
    `href' attribute value is not properly delimited. Third, don't use
    `javascript:' in the `href' attribute of an `a' element, unless you want to
    create a temporary document dynamically (which is the intent behind this URI
    scheme) or you need it as fallback for `onclick' in a dynamically generated
    pseudo-hyperlink. And finally, you can't know the real return value of that
    method because you do not evaluate it yet.
    Can execCommand() not take an argument for a
    file that is locatied in a different folder?
    The SaveAs command obviously pops up a "Save As" dialog in which the user
    would first select the local directory in which to save the file, and
    optionally change the filename or the file format before. It stands to
    reason that filenames cannot contain a slash character because it is used
    as path delimiter and option prefix already.
    How can this be done?
    Impossible code can be written in a number of ways. You have just
    discovered one, congratulations .
    And if I can prepopulate a target location on the user's machine that
    would be the best solution, (eg. c:\some folder\).
    Of course it wouldn't, because you cannot know which permissions are
    required to write to the parent directory, and in particular if the user
    running the browser has the necessary privileges.
    I don't think that is possible with javascript because of security,
    but I may be wrong.
    You don't appear to think clearly. "javascript " doesn't even enter into
    it, this is a feature of the (MSHTML) DOM. And security has little to do
    with it.
    window.location () will take in a folder, so I can always fall back on
    that.
    window.location is not a method to begin with, and it certainly cannot be
    assigned a folder, only maybe a URI that refers to a local directory if the
    user agent supports that and it complies with the Same Origin Policy.

    As I have said, you are really either very confused or completely clueless.
    If the former, take a break; if the latter, you should get the basics right
    by RTFM before you try to mess with the user's software and filesystem.

    <http://msdn.microsoft. com/en-us/library/ms536419(VS.85) .aspx>


    PointedEars
    --
    Prototype.js was written by people who don't know javascript for people
    who don't know javascript. People who don't know javascript are not
    the best source of advice on designing systems that use javascript.
    -- Richard Cornford, cljs, <f806at$ail$1$8 300dec7@news.de mon.co.uk>

    Comment

    Working...