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