1)上傳文件直接用h5中的<input type="file" >
2)調用手機攝像頭上傳圖片則是:
<input type="file" accept="image/*" capture="camera">
<input type="file" accept="video/*" capture="camcorder">
<input type="file" accept="audio/*" capture="microphone">
capture表示,可以捕獲到系統默認的設備,
比如:camera--照相機;camcorder--攝像機;microphone--錄音。
accept表示,直接打開系統文件目錄。
其實html5的input:file標簽還支持一個multiple屬性,表示可以支持多選,如:
加上這個multiple后,capture就沒啥用了,因為multiple是專門yong用來支持多選的。
針對 2)直接調用手機的拍照功能,對於安卓系統的某些內置瀏覽器限制 是無法獲取成功的(andriod webview考慮安全原因屏蔽了,<input type="file" />這個功能)
解決方案:重寫webview的WebChromeClient(非前端可操作)
參考資料:
http://blog.csdn.net/huangwenkui1990/article/details/51967464
http://blog.csdn.net/hvkcoder/article/details/51365191
http://www.jianshu.com/p/48e688ce801f