Web Analytics Made Easy -
StatCounter CopyFile or something else - want simple copy of a file - CodingForum

Announcement

Collapse
No announcement yet.

CopyFile or something else - want simple copy of a file

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • CopyFile or something else - want simple copy of a file

    New to Javascript.

    All I want to do is prompt a user for a source file name (which will include a drive letter) and copy that file to a destination (right now, default, hard-coded folder name). Any help?

    Thanks!

    ****************

    <html>

    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Form input</title>

    <SCRIPT language = "JavaScript">

    <!--
    function Button1_OnClick(form) {
    var fso, fl;

    fname_str = form.fName.value;
    if (fname_str.length < 1) {
    alert("You didn't enter a file name");
    return;
    }

    fso = new ActiveXObject("Scripting.FileSystemObject");
    fileObj = fso.GetFile(fname_str);
    fso.CopyFile(fileObj, "D:\\MicroSurvey\\WorkFiles\\"+fname_str, true);

    return;
    }

    function fName_OnBlur(form) {
    fname_str = form.fName.value;

    if (fname_str.length < 1) {
    alert("You didn't enter a file name");
    return;
    }

    return;

    }
    //-->
    </script>

    </head>



    <body bgcolor="#C0C0C0">

    <h3>Button Test</h3>

    <hr>

    <br>
    Enter the file name, including drive letter (e.g., H and path<br>
    &nbsp;&nbsp;&nbsp;&nbsp;For example, H:\username\foldername\projectname<br>
    <br>

    <hr>


    <form name="ValidForm">
    <p>
    File Name To Be Copied:&nbsp;&nbsp;
    <input type="text" size="25" name="fName" onBlur="fName_OnBlur(this.form)">
    <br><br>
    This file will be copied to <b>D:\MicroSurvey\WorkFiles</b>
    <br><br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="button" name="Button1" value=" OK " onClick="Button1_OnClick(this.form)">
    <hr>
    <br><br>
    <input type="button" value="Close this window" onClick="window.close()">
    </p>
    </form>


    </body>
    </html>

  • #2
    So you want a user to be able to copy a file on his/her computer to another destination on his/her computer, or to a destination on a remote computer?

    The latter case would need to use a serverside language, such as PHP or ASP or CGI perhaps.

    The former case I don't think can be done using Javascript especially using a web browser since this is a security risk.

    If you really need this done in a web browser, you have to look at who's going to be using this. If they are going to be Windows users, or users on an Intranet that trust you, you could develop an ActiveX control to do this.

    I don't know too much on these topics, perhaps someone else on this board can be of further assistance.

    Hope that helps,
    Sadiq.

    Comment


    • #3
      Maybe not Javascript? What else?

      Maybe Javascript isn't the answer.

      We have some (most) users that do not know how to use My Computer to locate files let alone copy them from one folder to another. The test group would be copying files from the network (proper permissions set) to their hard drives. I was hoping to simplify things for both me and them by creating a simple prompt, push a button, and have the copy done in the background for them. We could tell them what browser, etc. they would have to use. I started out trying BAT files and progressed to Javascript.

      This would all be handled in-house (not on the web), just our users copying files. Just want an oversimplified way of doing this for them.

      Any ideas?

      Comment


      • #4
        When you say simple, do you want it to be simple for the developers, or simple for the end-users?

        If you could be a little more specific as to what you maybe want the interface to look like, that would help. Is this for backup purposes, or what?

        I don't know too much about them, but if you want this to be a web-based app, then I think an ActiveX control would be your best bet.

        I'm not sure what's easiest since I don't know to what lengths they want to do thing.

        How do they plan on finding these files that they want to copy? Using a browse button? This is basically just using the My Computer interface to some extent.

        If there is a particular folder that they will ALWAYS be copying files to, you may just want to setup a shortcut on their desktop or some place easy allowing them to drag and drop their files into this folder? Just shooting out ideas here...

        Anyway, good luck with it,
        Sadiq.

        Comment


        • #5
          This might have all the answers: Microsoft Windows 2000 Scripting Guide
          hmm... ?

          Comment


          • #6
            I suggest dropping the web interface and follow sad69's advice of putting shorcut to the network shared folder (source) and shortcut to My Computer (destination) to the users' desktop. Then instruct them to drag and drop files from the source to destination to copy files. If users are not really that computer savvy, you can create a simple document or web page that contains the step by step instructions on copying files.
            Glenn
            vBulletin Mods That Rock!

            Comment


            • #7
              Thanks

              I was trying to keep it extremely simple for the end users.

              I was also hoping to learn a little Javascript on the way.

              It seems as if creating some simple instructions and educating the users is probably my best bet.

              Thanks everyone.


              HOWEVER, if someone does come up with a Javascript (or other) solution, I'd still like to see it.

              Comment

              Working...
              X