Home > Web Front-end > H5 Tutorial > body text

When uploading pictures using html5, both the IOS system and the Android system display camera photography and picture selection.

巴扎黑
Release: 2018-05-12 13:56:55
Original
4656 people have browsed it

Recently when I was doing letter development, I found that in IOS, you can take a photo or select from the photo gallery, while the Android system displays the resource manager without a photo option, and you can search for information online. After changing to capture="camera">, Android can display the camera and documents, but IOS only has a photo option. Finally, the device is judged The type enables the display of photo taking and gallery selection under both IOS and Android. The code is as follows:

var u = navigator.userAgent, app = navigator.appVersion;  
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //android终端或者uc浏览器  
var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端  
//alert('是否是Android:'+isAndroid);  
//alert('是否是iOS:'+isiOS);
 if(isAndroid){
          $ ("input[name='file']").attr('capture','camera');
 }
Copy after login

Android effect

IOS effect

The above is the detailed content of When uploading pictures using html5, both the IOS system and the Android system display camera photography and picture selection.. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template