图像从浏览器保存到手机图库 [英] Save an image to a mobile phone gallery from a browser
问题描述
所以,这似乎不太可能纯粹从安全角度考虑,但我需要支付我的基地。有没有人碰到一个方法,在浏览器用户的画廊保存图像?在这种情况下,我专门谈从网站提供的JavaScript(不PhoneGap的)。
So this seems unlikely purely from a security point of view, but I need to cover my bases. Has anyone come across a method for saving an image in a browser to the user's gallery? In this case, I'm specifically talking about from site served javascript (not phonegap).
虽然我知道你可以点击并按住图片保存,我喜欢一个按钮,我们的技术不太倾向于用户。
While I know you can tap and hold on the image to save, I'd love a button for our less technically inclined users.
电话生态系统是多样的,所以任何手机会为我工作。我只是好奇,如果可能的话。
The phone ecosystem is diverse, so any phone would work for me. I'm just curious if it's possible.
一些尝试:
工程于桌面上,手机链,通过(Android版)
<a href="logo.png" download="logo.png">
<img src="logo.png" alt="">
</a>
挂起点击时(Android版)
<一个href=\"http://stackoverflow.com/questions/7951326/save-image-to-users-disk-using-javascript/7952401#7952401\">save图像用户的磁盘使用javascript
推荐答案
如何
function save(){
document.addEventListener("deviceready", onDeviceReady, false);
}
function onDeviceReady() {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
}
function gotFS(fileSystem) {
fileSystem.root.getFile("pic.jpg", {create: true, exclusive: false}, gotFileEntry, fail);
}
function gotFileEntry(fileEntry) {
fileEntry.createWriter(gotFileWriter, fail);
}
function gotFileWriter(writer) {
var photo = document.getElementById("image");
writer.write(photo.value);
}
function fail(error) {
console.log(error.code);
}
这篇关于图像从浏览器保存到手机图库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!