When uploading html5 images, both IOS and Android display camera photos and image selection,

Source: Internet
Author: User

When uploading html5 images, both IOS and Android display camera photos and image selection,

Recently, when sending and writing a letter, I found that <input type = "file"/> in IOS, you can take a photo or select from the photo gallery. In Android, the resource manager is displayed, and there is no photo option, search for information online and change it to <input type = "file"Capture ="Camera"> Later, Android can display cameras and documents, but IOS only has the photo option. Finally, by judging the device type, both IOS and Android can display photos and Image Library options, the Code is as follows:

Var u = navigator. userAgent, app = navigator. appVersion;
Var isAndroid = u. indexOf ('android')>-1 | u. indexOf ('linux ')>-1; // Android terminal or uc Browser
Var isiOS = !! U. match (/\ (I [^;] +; (U ;)? CPU. + Mac OS X/); // ios Terminal
// Alert ('Whether it is Android: '+ isAndroid );
// Alert ('Whether it is iOS: '+ isiOS );

If (isAndroid ){
$ ("Input [name = 'file']"). attr ('capture', 'cama ');
}

 

Android Effect

 

 

IOS Effect

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.