强制输入类型为“文件".在手机上打开画廊 [英] Force <input type="file"> to open gallery in mobile

查看:125
本文介绍了强制输入类型为“文件".在手机上打开画廊的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想输入的内容仅接受来自图库的文件,而不是允许用户打开相机.
我该如何实现?

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

<asp:FileUpload ID="filGallery" runat="server" AllowMultiple="true" />

HTML 5

<input type="file" id="filGallery" multiple="multiple" />

我想要的行为类似于iOS 8或更低版本中的行为,其中启用了多个文件的输入无法打开相机

The behaviour I want is similar to the one found in iOS 8 or less, where input with multiple files enabled couldn't open the camera

推荐答案

我不认为有一种强制使用图库的方法-当前的趋势更多是使用摄像头(并建议使用正面或背面)而不是禁用它

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.

但是,关于SO有一个类似的问题(但重点是捕获类型),在该问题中,回答者指出了您可以尝试使用的一些输入属性方法:

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:

原始SO: https://stackoverflow.com/a/40512470/2564920

他已经完成了有关移动捕获的更多详细测试: https://addpipe.com/blog/correct-syntax-html-media-capture/

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

您可以试用的测试页: https://addpipe.com/html- media-capture-demo/

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

具体是一种设置

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

看起来很有希望-但可能行不通(因为不赞成使用此语法,并且较新的规范中的capture属性用于表示您要使用摄像头-在前置或后置摄像头之间进行选择

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)

这篇关于强制输入类型为“文件".在手机上打开画廊的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆