FileUpload FileSpec

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rory Becker

    FileUpload FileSpec

    Is there any way to tell the FileUpload control to produce a clientside dialog
    with a particular filespec filter on it.

    For example I would like to restrict users to only uploading pdf files.

    Thanks

    --
    Rory


  • Juan T. Llibre

    #2
    Re: FileUpload FileSpec

    if (FileUpload1.Ha sFile)
    {
    string filename = FileUpload1.Fil eName;
    string extension = System.IO.Path. GetExtension(Fi leUpload1.FileN ame);
    if (extension == ".pdf")
    {
    //your upload code...
    }
    }




    Juan T. Llibre, asp.net MVP
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    =============== =============== ========
    "Rory Becker" <rorybecker@new sgroup.nospamwr ote in message news:3af103471d 41e8cad1b57b35b d3b@news.micros oft.com...
    Is there any way to tell the FileUpload control to produce a clientside dialog with a particular filespec filter on
    it.
    >
    For example I would like to restrict users to only uploading pdf files.
    >
    Thanks
    >
    --
    Rory
    >
    >


    Comment

    • Rory Becker

      #3
      Re: FileUpload FileSpec

      Hello Juan,
      if (FileUpload1.Ha sFile)
      {
      string filename = FileUpload1.Fil eName;
      string extension = System.IO.Path. GetExtension(Fi leUpload1.FileN ame);
      if (extension == ".pdf")
      {
      //your upload code...
      }
      }
      Thanks Juan. I already have something like that on the server-side.

      I was hoping however to present the user of my site with a slightly friendlier
      interface by masking out everything other than pdfs in the dialog itself.

      Looking around the net it doesn't seem like it's possible though.

      --
      Rory


      Comment

      • Patrice

        #4
        Re: FileUpload FileSpec

        According to w3.org you could try the "accept" attribute :



        that said I'm not sure this is widely supported...

        --
        Patrice

        "Rory Becker" <rorybecker@new sgroup.nospama écrit dans le message de
        groupe de discussion : 3af103471d42b8c ad1b833c40b99@n ews.microsoft.c om...
        Hello Juan,
        >
        >if (FileUpload1.Ha sFile)
        >{
        >string filename = FileUpload1.Fil eName;
        >string extension = System.IO.Path. GetExtension(Fi leUpload1.FileN ame);
        >if (extension == ".pdf")
        >{
        >//your upload code...
        >}
        >}
        >
        Thanks Juan. I already have something like that on the server-side.
        >
        I was hoping however to present the user of my site with a slightly
        friendlier interface by masking out everything other than pdfs in the
        dialog itself.
        >
        Looking around the net it doesn't seem like it's possible though.
        >
        --
        Rory
        >
        >

        Comment

        Working...