JS File Input Restricting

Discussion in 'JavaScript' started by Pudge1, Jun 6, 2010.

  1. #1
    I know there is some way (I am not sure if it is with JavaScript) that you can restrict the files that people can see when they click the browse button on the file input. I am checking it again with PHP when it submits of course but this would make it easier while people are uploading their files. I have looked around but can't find much and don't know the search term to use. I have also tried the HTML accept attribute but that didn't work:
    <input type="file" name="file1" id="upload1" accept="image/gif" /> it just showed all files. I can't remember where I have seen this before though so I can't check their code.
     
    Pudge1, Jun 6, 2010 IP
  2. wmhelp

    wmhelp Peon

    Messages:
    29
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    wmhelp, Jun 7, 2010 IP
  3. Pudge1

    Pudge1 Well-Known Member

    Messages:
    912
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    140
    Digital Goods:
    1
    #3
    I tried it and it didn't work with FireFox, Chrome or IE.
     
    Pudge1, Jun 8, 2010 IP
  4. krsix

    krsix Peon

    Messages:
    435
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #4
    you should be doing this on the server side, assume EVERYTHING from client is malicious.
     
    krsix, Jun 10, 2010 IP
  5. Pudge1

    Pudge1 Well-Known Member

    Messages:
    912
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    140
    Digital Goods:
    1
    #5
    I am, I just want to do this so people can find the right images easier and quicker.
     
    Pudge1, Jun 13, 2010 IP
  6. makechapman

    makechapman Greenhorn

    Messages:
    80
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #6
    <form enctype="multipart/form-data">
     
    makechapman, Jun 14, 2010 IP
  7. Pudge1

    Pudge1 Well-Known Member

    Messages:
    912
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    140
    Digital Goods:
    1
    #7
    ...How would that help?
     
    Pudge1, Jun 14, 2010 IP