In a previous company to do an app inside the upload avatar function, then studied for a long time, found an article about the H5 Camera and album calls, so it solved the problem!! I record here so that some people need, can refer to!!!!
The following is a complete HTML page content, placed on the server and then browse on it, only support chrome and Safari core browser, QQ browser, Chrome,safari browser can be. Different phones and browsers do not show the same way.
<! DOCTYPE html>
<title> Upload Images </title>
<meta charset= "Utf-8" >
<body>
<iframe name= "uploadfrm" id= "uploadfrm" style= "Display:none;" ></iframe>
<form name= "Formhead" method= "post" action= "id=" Formhead "enctype=" Multipart/form-data "target=" Uploadfrm ">
<div>
<div>
<input type= "File" Name= "File_head" id= "File_head" onchange= "Javascript:setimagepreview ();"/>
</div>
<div>
<div id= "Divup" style= "Display:none" >
<input type= "Submit" data-inline= "true" id= "Btnup" value= "Confirm upload" data-mini= "true"/>
</div>
</div>
</div>
</form>
<div data-role= "Fieldcontain" >
<div id= "Localimag" >
</div>
</div>
<script type= "Text/javascript" >
function Setimagepreview () {
var preview, Img_txt, localimag, File_head = document.getElementById ("File_head"),
Picture = File_head.value;
if (!picture.match (/.jpg|. Gif|. Png|. bmp/i) return alert ("The image you uploaded is not in the correct format, please re-select!") "),
!1;
if (preview = document.getElementById ("preview"), File_head.files && file_head.files[0]) Preview.style.display = "Block",
Preview.style.width = "63px",
Preview.style.height = "63px",
PREVIEW.SRC = Window.navigator.userAgent.indexOf ("Chrome") >= 1 | | Window.navigator.userAgent.indexOf ("Safari") >= 1? Window.webkitURL.createObjectURL (File_head.files[0]): window. Url.createobjecturl (File_head.files[0]);
else {
File_head.select (),
File_head.blur (),
Img_txt = Document.selection.createRange (). Text,
Localimag = document.getElementById ("Localimag"),
LocalImag.style.width = "63px",
LocalImag.style.height = "63px";
try {
LocalImag.style.filter = "Progid:DXImageTransform.Microsoft.AlphaImageLoader (Sizingmethod=scale)",
LocalImag.filters.item ("DXImageTransform.Microsoft.AlphaImageLoader"). src = img_txt
} catch (f) {
Return alert ("The image you uploaded is not in the correct format, please re-select!") "),
!1
}
Preview.style.display = "None",
Document.selection.empty ()
}
return document.getElementById ("Divup"). Style.display = "Block",
!0
}
</script>
</body>
Web call Android, iphone camera, local pictures and files