Selecting a file client side

Discussion in 'ASP .Net' started by Dave56, Aug 2, 2004.

  1. Dave56

    Dave56 Guest

    Hi.

    I know how to use <input type=file runat=server> to upload a file to the
    webserver.
    However, my files are 2gb and I don't want to up load them.

    What I would like to be able to do is to just get the filename of the file
    the user selected (for example "c:\temp\movie.wmv").
    I also want validation that requires the selection of a .wmv file.

    What is the best way to do that?

    Thanks
     
    Dave56, Aug 2, 2004
    #1
    1. Advertising

  2. Dave56

    Ken Guest

    Add this to the HTML designer page

    <INPUT id="MyFile" type="file" name="MyFile" runat="server">

    Then you can refer to the 'MyFile' object in the code behind.

    MyFile.PostedFile.FileName



    "Dave56" <> wrote in message
    news:...
    > Hi.
    >
    > I know how to use <input type=file runat=server> to upload a file to the
    > webserver.
    > However, my files are 2gb and I don't want to up load them.
    >
    > What I would like to be able to do is to just get the filename of the file
    > the user selected (for example "c:\temp\movie.wmv").
    > I also want validation that requires the selection of a .wmv file.
    >
    > What is the best way to do that?
    >
    > Thanks
    >
    >
     
    Ken, Aug 2, 2004
    #2
    1. Advertising

  3. Dave56

    Dave56 Guest

    Thanks,

    I have tried that, but .net is automatically setting the Enctype property of
    the HtmlForm to "multipart/form-data".
    So it is trying to upload the file.

    MSDN says:
    When uploading large files, use the maxRequestLength attribute of the
    <httpRuntime> element to increase the maximum allowable file size. A DNS
    error is generated in the browser when the file exceeds the specified size.

    Since the file is huge I get this error.

    Besides, I just want the name of the file and not to actually have it
    uploaded.

    Is there any way to get around this?

    Dave56


    "Ken" <> wrote in message
    news:uK8qi$...
    > Add this to the HTML designer page
    >
    > <INPUT id="MyFile" type="file" name="MyFile" runat="server">
    >
    > Then you can refer to the 'MyFile' object in the code behind.
    >
    > MyFile.PostedFile.FileName
    >
    >
    >
    > "Dave56" <> wrote in message
    > news:...
    > > Hi.
    > >
    > > I know how to use <input type=file runat=server> to upload a file to the
    > > webserver.
    > > However, my files are 2gb and I don't want to up load them.
    > >
    > > What I would like to be able to do is to just get the filename of the

    file
    > > the user selected (for example "c:\temp\movie.wmv").
    > > I also want validation that requires the selection of a .wmv file.
    > >
    > > What is the best way to do that?
    > >
    > > Thanks
    > >
    > >

    >
    >
     
    Dave56, Aug 2, 2004
    #3
  4. He said he didn't want to upload them. If you put an input type=file HTML
    element in a page, and the user browses to a file and submits the form, the
    file will be uploaded, regardless of whether the app saves it or not. With a
    2GB file, this could take quite a while to run.

    Unfortunately, there is no HTML element for simply picking a file name.
    There are a couple of alternatives:

    1. Use the input type=file to have the user browse for the file. On submit,
    copy the value from the input type=file element, and put it into a hidden
    form field. Then remove it from the input type=file field, so that it
    doesn't upload.
    2. Write a client-side ActiveX control or Java applet to do this.

    --
    HTH,
    Kevin Spencer
    ..Net Developer
    Microsoft MVP
    Big things are made up
    of lots of little things.

    "Ken" <> wrote in message
    news:uK8qi$...
    > Add this to the HTML designer page
    >
    > <INPUT id="MyFile" type="file" name="MyFile" runat="server">
    >
    > Then you can refer to the 'MyFile' object in the code behind.
    >
    > MyFile.PostedFile.FileName
    >
    >
    >
    > "Dave56" <> wrote in message
    > news:...
    > > Hi.
    > >
    > > I know how to use <input type=file runat=server> to upload a file to the
    > > webserver.
    > > However, my files are 2gb and I don't want to up load them.
    > >
    > > What I would like to be able to do is to just get the filename of the

    file
    > > the user selected (for example "c:\temp\movie.wmv").
    > > I also want validation that requires the selection of a .wmv file.
    > >
    > > What is the best way to do that?
    > >
    > > Thanks
    > >
    > >

    >
    >
     
    Kevin Spencer, Aug 2, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. yaya coco
    Replies:
    1
    Views:
    416
    Rajesh Tiwari
    Jul 4, 2003
  2. moondaddy
    Replies:
    2
    Views:
    1,048
    Steven Cheng[MSFT]
    Jul 16, 2004
  3. Boss302
    Replies:
    0
    Views:
    1,070
    Boss302
    Nov 21, 2006
  4. Bogdan
    Replies:
    2
    Views:
    669
    Bogdan
    Jun 9, 2008
  5. Zoe Hart
    Replies:
    1
    Views:
    383
    Scott Wisniewski
    Jan 8, 2004
Loading...

Share This Page