INPUT Type="FILE" - Just want to get the file name and path as string

Discussion in 'ASP .Net' started by kevin@webpageconcepts.com, Aug 1, 2006.

  1. Guest

    Hi, I am trying to create a page so the user can browse the network,
    select a file and have that file name (text) inserted into our sql DB
    so I can build the hyperlink path later on.

    Here's what seems to be the problem. These are video files and are
    enormous with long crazy names so trying to hand type the file name in
    a text box is not an option. So I'm using an Input "file" control so
    when the user browses out onto the network (Z:\drive\videos), gets the
    file path into the Input file text box and then hits the insert control
    to process the filename it bombs because the files are too huge
    (100+MB). I just want to get the name to a string and not actually get
    the file.

    MyFile.PostedFile.FileName is great but it seems to have to process the
    file and not just give me the text of the file after I browsed.

    If this makes any sense, any help would be great. Thanks K
     
    , Aug 1, 2006
    #1
    1. Advertising

  2. It does. But short of using an ActiveX control, I don't think you'll find a
    workaround. Even JavaScript is extremely limited in what it can help you
    with - namely because of potential security issues.

    Karl

    --
    http://www.openmymind.net/
    http://www.fuelindustries.com/


    <> wrote in message
    news:...
    > Hi, I am trying to create a page so the user can browse the network,
    > select a file and have that file name (text) inserted into our sql DB
    > so I can build the hyperlink path later on.
    >
    > Here's what seems to be the problem. These are video files and are
    > enormous with long crazy names so trying to hand type the file name in
    > a text box is not an option. So I'm using an Input "file" control so
    > when the user browses out onto the network (Z:\drive\videos), gets the
    > file path into the Input file text box and then hits the insert control
    > to process the filename it bombs because the files are too huge
    > (100+MB). I just want to get the name to a string and not actually get
    > the file.
    >
    > MyFile.PostedFile.FileName is great but it seems to have to process the
    > file and not just give me the text of the file after I browsed.
    >
    > If this makes any sense, any help would be great. Thanks K
    >
     
    Karl Seguin [MVP], Aug 1, 2006
    #2
    1. Advertising

  3. The HtmlInputFile control sets the form's enctype to "multipart/form-data"
    in their OnPreRender methods, which is what causes the file to be uploaded.
    You could avoid this by creating your own file name control by subclassing
    the HtmlInputText control:

    using System;
    using System.Security.Permissions;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;

    [assembly: TagPrefix("Bordecal.Web.UI.HtmlControls", "bordecal")]

    namespace Bordecal.Web.UI.HtmlControls
    {
    [ValidationProperty("Value")]
    [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level =
    AspNetHostingPermissionLevel.Minimal)]
    [AspNetHostingPermission(SecurityAction.LinkDemand, Level =
    AspNetHostingPermissionLevel.Minimal)]
    public class HtmlInputFileName : HtmlInputText
    {
    public HtmlInputFileName()
    : base("file")
    {
    }
    }
    }

    The above control would expose the selected file name via its Value
    property.

    <> wrote in message
    news:...
    > Hi, I am trying to create a page so the user can browse the network,
    > select a file and have that file name (text) inserted into our sql DB
    > so I can build the hyperlink path later on.
    >
    > Here's what seems to be the problem. These are video files and are
    > enormous with long crazy names so trying to hand type the file name in
    > a text box is not an option. So I'm using an Input "file" control so
    > when the user browses out onto the network (Z:\drive\videos), gets the
    > file path into the Input file text box and then hits the insert control
    > to process the filename it bombs because the files are too huge
    > (100+MB). I just want to get the name to a string and not actually get
    > the file.
    >
    > MyFile.PostedFile.FileName is great but it seems to have to process the
    > file and not just give me the text of the file after I browsed.
    >
    > If this makes any sense, any help would be great. Thanks K
    >
     
    Nicole Calinoiu, Aug 1, 2006
    #3
  4. don't use the file control. have a page that builds a list doing a
    directory.

    -- bruce (sqlwork.com)


    <> wrote in message
    news:...
    > Hi, I am trying to create a page so the user can browse the network,
    > select a file and have that file name (text) inserted into our sql DB
    > so I can build the hyperlink path later on.
    >
    > Here's what seems to be the problem. These are video files and are
    > enormous with long crazy names so trying to hand type the file name in
    > a text box is not an option. So I'm using an Input "file" control so
    > when the user browses out onto the network (Z:\drive\videos), gets the
    > file path into the Input file text box and then hits the insert control
    > to process the filename it bombs because the files are too huge
    > (100+MB). I just want to get the name to a string and not actually get
    > the file.
    >
    > MyFile.PostedFile.FileName is great but it seems to have to process the
    > file and not just give me the text of the file after I browsed.
    >
    > If this makes any sense, any help would be great. Thanks K
    >
     
    bruce barker \(sqlwork.com\), Aug 2, 2006
    #4
  5. Guest

    Did it. Perfect. Thanks!


    bruce barker (sqlwork.com) wrote:
    > don't use the file control. have a page that builds a list doing a
    > directory.
    >
    > -- bruce (sqlwork.com)
    >
    >
     
    , Aug 2, 2006
    #5
    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. =?Utf-8?B?ZGFycmVu?=

    html input file - just want to browse

    =?Utf-8?B?ZGFycmVu?=, Jul 6, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    410
    =?Utf-8?B?ZGFycmVu?=
    Jul 6, 2004
  2. jonesy
    Replies:
    5
    Views:
    2,585
    Jukka K. Korpela
    Dec 13, 2006
  3. Replies:
    4
    Views:
    685
    Walter Roberson
    Sep 9, 2005
  4. Mike Schilling
    Replies:
    2
    Views:
    589
    Arne Vajhøj
    Mar 5, 2010
  5. PerlFAQ Server
    Replies:
    0
    Views:
    125
    PerlFAQ Server
    Jan 7, 2011
Loading...

Share This Page