Invoking a directory browse for file(s) download

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

    Invoking a directory browse for file(s) download

    As a "newbie" to Javascript I need some help with my latest problem...

    I have a number of image files that have been pre-selected by the user
    for downloading. I'd like to be able to have the user click a button
    and have a directory browser pop-up window available for the user to
    select the directory into which the image files will be downloaded.

    I thought that this would be simple to find but...

    If this is possible I further need to know:

    1) how to access the directory path string (which will be used to
    download the files)

    2) how to set any available default values for the directory bvrowser.

    I'd really appreciate anyone being able to point me in a direction.

    TIA
    Glenn
  • Jeff North

    #2
    Re: Invoking a directory browse for file(s) download

    On 20 Sep 2004 08:28:07 -0700, in comp.lang.javas cript
    gowens@nixonpea body.com (Glenn Owens) wrote:
    [color=blue]
    >| As a "newbie" to Javascript I need some help with my latest problem...
    >|
    >| I have a number of image files that have been pre-selected by the user
    >| for downloading. I'd like to be able to have the user click a button
    >| and have a directory browser pop-up window available for the user to
    >| select the directory into which the image files will be downloaded.
    >|
    >| I thought that this would be simple to find but...
    >|
    >| If this is possible I further need to know:
    >|
    >| 1) how to access the directory path string (which will be used to
    >| download the files)
    >|
    >| 2) how to set any available default values for the directory bvrowser.
    >|
    >| I'd really appreciate anyone being able to point me in a direction.[/color]

    If I understand you correctly then there is no need for this.
    If the user right mouse clicks the image then they can select Save As
    from the context menu. This in-turn will ask the user for the location
    to save the file to.
    ---------------------------------------------------------------
    jnorth@yourpant sbigpond.net.au : Remove your pants to reply
    ---------------------------------------------------------------

    Comment

    • Glenn Owens

      #3
      Re: Invoking a directory browse for file(s) download

      Not true. As I mentioned I need a way to download a number of image
      files from a gallery-style image search engine to a directory
      destination of the user's choosing. Selecting each image with a
      right-click and specifying the directory would be unnecessarily
      tedious for the user.

      I did find a way to involk the BrowseForFolder activeX control through
      Javascript out on MSDN. So, I implemented, and tested, the control and
      that seems to be working well. Here's the Javascript that I'm using:

      function GetDownloadPath () {
      var frm = document.forms[0];
      var Shell = new ActiveXObject(" Shell.Applicati on");
      var Folder = new Object;

      Folder = Shell.BrowseFor Folder(0, "Choose a download folder", 0);

      var FolderItem = new Object;
      FolderItem = Folder.Items(). Item();

      document.all.it em("lblFilepath ").InnerTex t = FolderItem.Path ;
      frm.lblFilepath .Text = FolderItem.Path ;
      }


      Now, my out question is how to get the client-side FilePath back to
      the server without a second round-trip to the server.

      Any thoughts wsould be appreciated.

      Glenn

      Comment

      • Jeff North

        #4
        Re: Invoking a directory browse for file(s) download

        On 21 Sep 2004 04:29:37 -0700, in comp.lang.javas cript
        gowens@nixonpea body.com (Glenn Owens) wrote:
        [color=blue]
        >| Not true. As I mentioned I need a way to download a number of image
        >| files from a gallery-style image search engine to a directory
        >| destination of the user's choosing. Selecting each image with a
        >| right-click and specifying the directory would be unnecessarily
        >| tedious for the user.[/color]

        The user only has to navigate to their folder once and it becomes the
        default folder so subsequent downloads go to that folder. The user can
        also rename the file if required.
        [color=blue]
        >| I did find a way to involk the BrowseForFolder activeX control through
        >| Javascript out on MSDN. So, I implemented, and tested, the control and
        >| that seems to be working well. Here's the Javascript that I'm using:
        >|
        >| function GetDownloadPath () {
        >| var frm = document.forms[0];
        >| var Shell = new ActiveXObject(" Shell.Applicati on");
        >| var Folder = new Object;
        >|
        >| Folder = Shell.BrowseFor Folder(0, "Choose a download folder", 0);
        >|
        >| var FolderItem = new Object;
        >| FolderItem = Folder.Items(). Item();
        >|
        >| document.all.it em("lblFilepath ").InnerTex t = FolderItem.Path ;
        >| frm.lblFilepath .Text = FolderItem.Path ;
        >| }[/color]

        I get 'Permission Denied' error message (WinXP SP2 IE6.0.29)

        Error: ActiveXObject is not defined (NS7.1 and Mozilla1.7)
        [color=blue]
        >| Now, my out question is how to get the client-side FilePath back to
        >| the server without a second round-trip to the server.[/color]

        You can't.
        ---------------------------------------------------------------
        jnorth@yourpant sbigpond.net.au : Remove your pants to reply
        ---------------------------------------------------------------

        Comment

        • Lee

          #5
          Re: Invoking a directory browse for file(s) download

          Glenn Owens said:[color=blue]
          >
          >Not true. As I mentioned I need a way to download a number of image
          >files from a gallery-style image search engine to a directory
          >destination of the user's choosing. Selecting each image with a
          >right-click and specifying the directory would be unnecessarily
          >tedious for the user.
          >
          >I did find a way to involk the BrowseForFolder activeX control through
          >Javascript out on MSDN. So, I implemented, and tested, the control and
          >that seems to be working well. Here's the Javascript that I'm using:
          >
          >function GetDownloadPath () {
          > var frm = document.forms[0];
          > var Shell = new ActiveXObject(" Shell.Applicati on");
          > var Folder = new Object;
          >
          > Folder = Shell.BrowseFor Folder(0, "Choose a download folder", 0);
          >
          > var FolderItem = new Object;
          > FolderItem = Folder.Items(). Item();
          >
          > document.all.it em("lblFilepath ").InnerTex t = FolderItem.Path ;
          > frm.lblFilepath .Text = FolderItem.Path ;
          >}
          >
          >
          >Now, my out question is how to get the client-side FilePath back to
          >the server without a second round-trip to the server.
          >
          >Any thoughts wsould be appreciated.[/color]

          Jeff is not just being difficult. What you're asking for would
          be a serious security breach. If your code can decide where to
          put things, what would prevent you from putting things in my
          system directories? Only a few browsers with little respect for
          the user's security allow any access to the user's filesystem at
          all.

          Comment

          • Glenn Owens

            #6
            Re: Invoking a directory browse for file(s) download

            Mr. North,

            As we are a Microsoft shop I'n less concerned over the fact that this
            is the first time I'm used Microsoft-only controls (though I do try to
            remain agnostic as to the platform. We are using WinXP SP1 IE6.0.28)
            and the Shell.BrowseFro Folder is working well - no access errors. The
            website is configured for Windows Authentication (only) and the
            web.config file provides the ASPNET_WP with impersonation rights.

            As far as getting the Filepath back from the client without a second
            roundtrip (the first was to initiate the image download via an asp
            button click)... this bacame easy to accomplish with a bit of
            JavaScript and a "hidden" HTML input field in the form.

            So, while - yes, I'm not addressing the NS and Mozilla users (of which
            we have none) the remainder of the image search/engine/gallery
            upload/download works just fine.

            Glenn


            Jeff North <jnorth@yourpan tsbigpond.net.a u> wrote in message news:<1ej0l0t0i 4qva4akh98agpm9 ggfrj5gkoh@4ax. com>...[color=blue]
            > On 21 Sep 2004 04:29:37 -0700, in comp.lang.javas cript
            > gowens@nixonpea body.com (Glenn Owens) wrote:
            >[color=green]
            > >| Not true. As I mentioned I need a way to download a number of image
            > >| files from a gallery-style image search engine to a directory
            > >| destination of the user's choosing. Selecting each image with a
            > >| right-click and specifying the directory would be unnecessarily
            > >| tedious for the user.[/color]
            >
            > The user only has to navigate to their folder once and it becomes the
            > default folder so subsequent downloads go to that folder. The user can
            > also rename the file if required.
            >[color=green]
            > >| I did find a way to involk the BrowseForFolder activeX control through
            > >| Javascript out on MSDN. So, I implemented, and tested, the control and
            > >| that seems to be working well. Here's the Javascript that I'm using:
            > >|
            > >| function GetDownloadPath () {
            > >| var frm = document.forms[0];
            > >| var Shell = new ActiveXObject(" Shell.Applicati on");
            > >| var Folder = new Object;
            > >|
            > >| Folder = Shell.BrowseFor Folder(0, "Choose a download folder", 0);
            > >|
            > >| var FolderItem = new Object;
            > >| FolderItem = Folder.Items(). Item();
            > >|
            > >| document.all.it em("lblFilepath ").InnerTex t = FolderItem.Path ;
            > >| frm.lblFilepath .Text = FolderItem.Path ;
            > >| }[/color]
            >
            > I get 'Permission Denied' error message (WinXP SP2 IE6.0.29)
            >
            > Error: ActiveXObject is not defined (NS7.1 and Mozilla1.7)
            >[color=green]
            > >| Now, my out question is how to get the client-side FilePath back to
            > >| the server without a second round-trip to the server.[/color]
            >
            > You can't.
            > ---------------------------------------------------------------
            > jnorth@yourpant sbigpond.net.au : Remove your pants to reply
            > ---------------------------------------------------------------[/color]

            Comment

            • Jeff North

              #7
              Re: Invoking a directory browse for file(s) download

              On 28 Sep 2004 13:59:55 -0700, in comp.lang.javas cript
              gowens@nixonpea body.com (Glenn Owens) wrote:
              [color=blue]
              >| Mr. North,
              >|
              >| As we are a Microsoft shop I'n less concerned over the fact that this
              >| is the first time I'm used Microsoft-only controls (though I do try to
              >| remain agnostic as to the platform. We are using WinXP SP1 IE6.0.28)
              >| and the Shell.BrowseFro Folder is working well - no access errors. The
              >| website is configured for Windows Authentication (only) and the
              >| web.config file provides the ASPNET_WP with impersonation rights.[/color]

              Fine, considering none of this was mentioned in your original posting.
              Where did you get this control from, why not contact them for support?
              [color=blue]
              >| As far as getting the Filepath back from the client without a second
              >| roundtrip (the first was to initiate the image download via an asp
              >| button click)... this bacame easy to accomplish with a bit of
              >| JavaScript and a "hidden" HTML input field in the form.[/color]

              The fact still remains that you can't send information back to the
              server without re-submitting the page.

              You could use a frameset. The first frame being hidden (sized and
              positioned out of the way on the page). The second page would
              communicate with the first frame. The first frame would transmit this
              information to the server.
              [color=blue]
              >| So, while - yes, I'm not addressing the NS and Mozilla users (of which
              >| we have none) the remainder of the image search/engine/gallery
              >| upload/download works just fine.
              >|
              >| Glenn
              >|
              >|
              >| Jeff North <jnorth@yourpan tsbigpond.net.a u> wrote in message news:<1ej0l0t0i 4qva4akh98agpm9 ggfrj5gkoh@4ax. com>...
              >| > On 21 Sep 2004 04:29:37 -0700, in comp.lang.javas cript
              >| > gowens@nixonpea body.com (Glenn Owens) wrote:
              >| >
              >| > >| Not true. As I mentioned I need a way to download a number of image
              >| > >| files from a gallery-style image search engine to a directory
              >| > >| destination of the user's choosing. Selecting each image with a
              >| > >| right-click and specifying the directory would be unnecessarily
              >| > >| tedious for the user.
              >| >
              >| > The user only has to navigate to their folder once and it becomes the
              >| > default folder so subsequent downloads go to that folder. The user can
              >| > also rename the file if required.
              >| >
              >| > >| I did find a way to involk the BrowseForFolder activeX control through
              >| > >| Javascript out on MSDN. So, I implemented, and tested, the control and
              >| > >| that seems to be working well. Here's the Javascript that I'm using:
              >| > >|
              >| > >| function GetDownloadPath () {
              >| > >| var frm = document.forms[0];
              >| > >| var Shell = new ActiveXObject(" Shell.Applicati on");
              >| > >| var Folder = new Object;
              >| > >|
              >| > >| Folder = Shell.BrowseFor Folder(0, "Choose a download folder", 0);
              >| > >|
              >| > >| var FolderItem = new Object;
              >| > >| FolderItem = Folder.Items(). Item();
              >| > >|
              >| > >| document.all.it em("lblFilepath ").InnerTex t = FolderItem.Path ;
              >| > >| frm.lblFilepath .Text = FolderItem.Path ;
              >| > >| }
              >| >
              >| > I get 'Permission Denied' error message (WinXP SP2 IE6.0.29)
              >| >
              >| > Error: ActiveXObject is not defined (NS7.1 and Mozilla1.7)
              >| >
              >| > >| Now, my out question is how to get the client-side FilePath back to
              >| > >| the server without a second round-trip to the server.
              >| >
              >| > You can't.
              >| > ---------------------------------------------------------------
              >| > jnorth@yourpant sbigpond.net.au : Remove your pants to reply
              >| > ---------------------------------------------------------------[/color]

              ---------------------------------------------------------------
              jnorth@yourpant sbigpond.net.au : Remove your pants to reply
              ---------------------------------------------------------------

              Comment

              Working...