Force <input type=“file”> to open gallery in mobile

前端 未结 2 858
日久生厌
日久生厌 2021-01-17 23:18

I want to make my input to only accept files from gallery instead of allowing the user to open the camera.
How can I achieve it?

ASP.NET

相关标签:
2条回答
  • 2021-01-17 23:50

    just use simple method to open gallery in mobile

      <input type="file" id="fileProfile2" name="fileProfile2"  accept="image/png,image/jpeg">
    
    0 讨论(0)
  • 2021-01-18 00:00

    I don't think there is a way to force using gallery - current trend is more on using camera (and suggesting using front or back) rather than disabling it.

    However, there is a similar question on SO (but focus on type of capture) where that answerer has pointed to some ways of input attribute you may try out:

    original SO: https://stackoverflow.com/a/40512470/2564920

    More detail test he has done regard to the mobile capture: https://addpipe.com/blog/correct-syntax-html-media-capture/

    A test page which you can try out: https://addpipe.com/html-media-capture-demo/

    specifically one setting which is

    <input type="file" accept="image/*" capture="filesystem">
    

    looks promising - but probably won't work (since this syntax is deprecated and capture attribute in newer spec is used to say you want to use camera - choosing between front or back camera source)

    0 讨论(0)
提交回复
热议问题