Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. input type ="file" control for file uploading.

input type ="file" control for file uploading.

Scheduled Pinned Locked Moved Web Development
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    ritu4321
    wrote on last edited by
    #1

    i want to apply filter so that only txt,doc,rtf files are seen . Others are not seen . Please let me know .

    C A J 3 Replies Last reply
    0
    • R ritu4321

      i want to apply filter so that only txt,doc,rtf files are seen . Others are not seen . Please let me know .

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Here[^]

      Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      1 Reply Last reply
      0
      • R ritu4321

        i want to apply filter so that only txt,doc,rtf files are seen . Others are not seen . Please let me know .

        A Offline
        A Offline
        alaki_p
        wrote on last edited by
        #3

        Hi dude... try it... ========================================================= function checkFileExtension(elem) { var filePath = elem.value; if(filePath.indexOf('.') == -1) return false; var validExtensions = new Array(); var ext = filePath.substring(filePath.lastIndexOf('.') + 1).toLowerCase(); validExtensions[0] = 'txt'; validExtensions[1] = 'doc'; validExtensions[2] = 'rtf'; for(var i = 0; i < validExtensions.length; i++) { if(ext == validExtensions[i]) return true; } alert ('You Cant upload a '+ext.toUpperCase()+' file!'); return false; } ============================================================ * and now use this line in your code behind (this line used in VB.Net!!!) =========================================================== myfile.Attributes.Add("onchange", "return checkFileExtension(this);") ============================================================ :rolleyes: be cool...

        R 1 Reply Last reply
        0
        • A alaki_p

          Hi dude... try it... ========================================================= function checkFileExtension(elem) { var filePath = elem.value; if(filePath.indexOf('.') == -1) return false; var validExtensions = new Array(); var ext = filePath.substring(filePath.lastIndexOf('.') + 1).toLowerCase(); validExtensions[0] = 'txt'; validExtensions[1] = 'doc'; validExtensions[2] = 'rtf'; for(var i = 0; i < validExtensions.length; i++) { if(ext == validExtensions[i]) return true; } alert ('You Cant upload a '+ext.toUpperCase()+' file!'); return false; } ============================================================ * and now use this line in your code behind (this line used in VB.Net!!!) =========================================================== myfile.Attributes.Add("onchange", "return checkFileExtension(this);") ============================================================ :rolleyes: be cool...

          R Offline
          R Offline
          ritu4321
          wrote on last edited by
          #4

          thanks . i dont want validation. I want that only specified say excel file is seen no other file is seen. when i click browse of the control.

          1 Reply Last reply
          0
          • R ritu4321

            i want to apply filter so that only txt,doc,rtf files are seen . Others are not seen . Please let me know .

            J Offline
            J Offline
            Johnny
            wrote on last edited by
            #5

            You can't do this, other than using javascript to check the filename extension as someone else mentioned.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups