can take pictures or select from the photo gallery in IOS, while the Android system displays the resource manager and has no photo option. To search for information online, change it to , Android can display the camera and documents, but IOS only has photo options. Finally, by judging the device type, photo and gallery options can be displayed under both IOS and Android."/> can take pictures or select from the photo gallery in IOS, while the Android system displays the resource manager and has no photo option. To search for information online, change it to , Android can display the camera and documents, but IOS only has photo options. Finally, by judging the device type, photo and gallery options can be displayed under both IOS and Android.">

Home  >  Article  >  Web Front-end  >  When uploading pictures using html5, both the IOS system and the Android system display camera photography and picture selection.

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

巴扎黑
巴扎黑Original
2018-05-12 13:56:554623browse

Recently when I was doing letter development, I found that 61b9b53f6d762f7c3b14ccfc7d4eaf40 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 1ea02dab31a8f18102d082ef7d2f8a84, 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');
 }

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!

Statement:
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