Can we assign file extension using FileUpload

Discussion in 'ASP .Net' started by ad, Aug 18, 2005.

  1. ad

    ad Guest

    How can we assign file extension using FileUpload?
    ad, Aug 18, 2005
    #1
    1. Advertising

  2. ad

    Guest Guest

    What exactly are you trying to do and why?

    Tell us more about what you want to accomplish, there may be a better/easier
    way.

    -KF


    "ad" <> wrote in message
    news:%...
    > How can we assign file extension using FileUpload?
    >
    Guest, Aug 18, 2005
    #2
    1. Advertising

  3. ad

    ad Guest

    I want to uer upload a excel file, I want to limit the file extension to
    ".xls"


    <> ¼¶¼g©ó¶l¥ó·s»D:...
    > What exactly are you trying to do and why?
    >
    > Tell us more about what you want to accomplish, there may be a
    > better/easier way.
    >
    > -KF
    >
    >
    > "ad" <> wrote in message
    > news:%...
    >> How can we assign file extension using FileUpload?
    >>

    >
    >
    ad, Aug 18, 2005
    #3
  4. ad

    Mark Rae Guest

    "ad" <> wrote in message
    news:...

    >I want to uer upload a excel file, I want to limit the file extension to
    >".xls"


    protected HtmlInputFile txtFileName;

    if(Path.GetExtension(txtFileName.PostedFile.FileName) != ".xls"
    {
    // do something
    }
    Mark Rae, Aug 18, 2005
    #4
  5. you can use a asp:RegularExpressionValidator to validate file extensions

    a sample regular expression for XSL and CSV is

    ^[0-9A-Za-z_ ]+(.[xX][lL][sS]|.[cC][sS][vV])$

    i am not good in regular exps, following site got lot of samples

    http://www.regexlib.com/REDetails.aspx?regexp_id=259







    "Mark Rae" wrote:

    > "ad" <> wrote in message
    > news:...
    >
    > >I want to uer upload a excel file, I want to limit the file extension to
    > >".xls"

    >
    > protected HtmlInputFile txtFileName;
    >
    > if(Path.GetExtension(txtFileName.PostedFile.FileName) != ".xls"
    > {
    > // do something
    > }
    >
    >
    >
    =?Utf-8?B?U3JlZWppdGggUmFt?=, Aug 18, 2005
    #5
  6. ad

    ad Guest

    I have tried the RegularExpressionValidator , but no effect!


    "Sreejith Ram" <> ¼¶¼g©ó¶l¥ó·s»D:...
    > you can use a asp:RegularExpressionValidator to validate file extensions
    >
    > a sample regular expression for XSL and CSV is
    >
    > ^[0-9A-Za-z_ ]+(.[xX][lL][sS]|.[cC][sS][vV])$
    >
    > i am not good in regular exps, following site got lot of samples
    >
    > http://www.regexlib.com/REDetails.aspx?regexp_id=259
    >
    >
    >
    >
    >
    >
    >
    > "Mark Rae" wrote:
    >
    >> "ad" <> wrote in message
    >> news:...
    >>
    >> >I want to uer upload a excel file, I want to limit the file extension to
    >> >".xls"

    >>
    >> protected HtmlInputFile txtFileName;
    >>
    >> if(Path.GetExtension(txtFileName.PostedFile.FileName) != ".xls"
    >> {
    >> // do something
    >> }
    >>
    >>
    >>
    ad, Aug 18, 2005
    #6
  7. Well, the reason could be that the Regular expression you are using is wrong.
    You may want to test the expression with a RegularExpression tester to see
    if it works.

    I have used RegularExpressionValidator with file upload , in the past and it
    used to work. Do not have access to the code now to post sample



    "ad" wrote:

    > I have tried the RegularExpressionValidator , but no effect!
    >
    >
    > "Sreejith Ram" <> ¼¶¼g©ó¶l¥ó·s»D:...
    > > you can use a asp:RegularExpressionValidator to validate file extensions
    > >
    > > a sample regular expression for XSL and CSV is
    > >
    > > ^[0-9A-Za-z_ ]+(.[xX][lL][sS]|.[cC][sS][vV])$
    > >
    > > i am not good in regular exps, following site got lot of samples
    > >
    > > http://www.regexlib.com/REDetails.aspx?regexp_id=259
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > > "Mark Rae" wrote:
    > >
    > >> "ad" <> wrote in message
    > >> news:...
    > >>
    > >> >I want to uer upload a excel file, I want to limit the file extension to
    > >> >".xls"
    > >>
    > >> protected HtmlInputFile txtFileName;
    > >>
    > >> if(Path.GetExtension(txtFileName.PostedFile.FileName) != ".xls"
    > >> {
    > >> // do something
    > >> }
    > >>
    > >>
    > >>

    >
    >
    >
    =?Utf-8?B?U3JlZWppdGggUmFt?=, Aug 19, 2005
    #7
    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. William Buchanan

    Fileupload extension

    William Buchanan, Mar 15, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    2,818
    Steve C. Orr [MVP, MCSD]
    Mar 15, 2006
  2. Anand
    Replies:
    3
    Views:
    877
    Tim Daneliuk
    Nov 8, 2003
  3. Steve
    Replies:
    3
    Views:
    26,944
    Steve
    Aug 25, 2006
  4. llothar
    Replies:
    17
    Views:
    1,241
    Steve Holden
    Apr 7, 2008
  5. Michael
    Replies:
    3
    Views:
    193
    Jerry Goldin
    May 12, 2004
Loading...

Share This Page