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."> When uploading pictures using html5, both the IOS system and the Android system display camera photography and picture selection.-H5 Tutorial-php.cn

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
4556 people have browsed it

Recently when I was doing letter development, I found thatin 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 tocapture="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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!