FileUpload

Discussion in 'ASP .Net Web Controls' started by Victor Rodriguez, Apr 16, 2007.

  1. Is there a way to filter the file types when you use
    <asp:FileUpload></asp:FileUpload>? I would like to limit the user to import
    certain types of files.

    Thanks,

    Victor
     
    Victor Rodriguez, Apr 16, 2007
    #1
    1. Advertising

  2. Hi Victor,

    As for the <asp:FileUpload> control, it is rendered as html <input
    type="file" ..../> element. Therefore, if you want to prevent the client
    user from uploading certain type of file, you can consider use client-side
    script to check the value of the <input type="file"/> element. Use
    javascript to check the file extension to see whether the selected file is
    of a violate file type. BTW, for security reason, you can only read the
    value of <input type="file" /> element in script , but not set it due to
    security restriction.


    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    This posting is provided "AS IS" with no warranties, and confers no rights.
     
    Steven Cheng[MSFT], Apr 17, 2007
    #2
    1. Advertising

  3. Great, I'll do that. Another question, can I find out before hand the file
    size, before importing?

    thanks,

    Victor


    "Steven Cheng[MSFT]" <> wrote in message
    news:...
    > Hi Victor,
    >
    > As for the <asp:FileUpload> control, it is rendered as html <input
    > type="file" ..../> element. Therefore, if you want to prevent the client
    > user from uploading certain type of file, you can consider use client-side
    > script to check the value of the <input type="file"/> element. Use
    > javascript to check the file extension to see whether the selected file is
    > of a violate file type. BTW, for security reason, you can only read the
    > value of <input type="file" /> element in script , but not set it due to
    > security restriction.
    >
    >
    > Sincerely,
    >
    > Steven Cheng
    >
    > Microsoft MSDN Online Support Lead
    >
    >
    > This posting is provided "AS IS" with no warranties, and confers no
    > rights.
    >
    >
     
    Victor Rodriguez, Apr 17, 2007
    #3
  4. Thanks for your reply Victor,

    For get the file's size, I'm afraid pure script can not do this due to
    security restriction also. BTW, if you do need many powerful and complex
    control over the file uploading, I think a rich client solution would be
    preferred in such scenario. For example, activex control or IE hosted .net
    winform control .... And this is quite popular for intranet application
    since it is easier to ensure client's webbrowser security setting.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    This posting is provided "AS IS" with no warranties, and confers no rights.
     
    Steven Cheng[MSFT], Apr 18, 2007
    #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. grimBeast
    Replies:
    2
    Views:
    671
    MS News \(MS ILM\)
    Aug 27, 2003
  2. Edijer Sarmiento

    FileUpload limit problem

    Edijer Sarmiento, Jul 23, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    744
    Bryant Hankins
    Jul 23, 2004
  3. KK
    Replies:
    1
    Views:
    371
    Guest
    Jan 31, 2005
  4. Uncle Ben

    ASP.NET 2.0 FileUpload control

    Uncle Ben, Mar 23, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    3,786
    Bruce Barker
    Mar 23, 2005
  5. Jay
    Replies:
    2
    Views:
    798
    =?Utf-8?B?ZGdt?=
    May 23, 2005
Loading...

Share This Page