- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is there a sample or tutorial on how to download remote images with cordova plugins?
Here is the sample code of mine, displaying images after ajax succes.
<div class="image-wrap">
<div class="the-image">
<a href="https:sample.com/uploads/Sep-23-2016/89896787889.jpg" class="fancybox" rel="gallery">
<span class="attachment-wrap"><i class="fa fa-file-image-o" aria-hidden="true"></i> ..7889.jpg</span>
</a>
</div>
<div class="download-btn" >Download</div>
</div>
<div class="image-wrap">
<div class="the-image">
<a href="https:sample.com/uploads/Sep-22-2016/39495682191.jpg" class="fancybox" rel="gallery">
<span class="attachment-wrap"><i class="fa fa-file-image-o" aria-hidden="true"></i> ..2191.jpg</span>
</a>
</div>
<div class="download-btn" >Download</div>
</div>
Using the download button of each image how can I download image in phone's gallery. Andriod and IOS support. Any guide?
- Tags:
- HTML5
- Intel® XDK
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I use this code:
//função para buscar logotipo do cliente no servidor e guardar no aparelho
function funBaixaLogotipo(wLogotipo) {
var uri = encodeURI(wUrlLogotipo + wLogotipo);
var ft = new FileTransfer();
var options = new FileUploadOptions();
var headers={'Authorization':'authHeader'};
ft.download( uri, fileURL, function(entry) {
//alert("download complete: " + entry.toURL());
$("#imgLogotipo").attr("src", entry.toURL());
try {
if(typeof(window.localStorage) != 'undefined') {
window.localStorage.setItem("logotipo", "s");
}
else
{
alert('window.localStorage, not defined');
}
}
catch(err){
alert('store_local,error,' + err);
}
$.ui.loadContent("#pagPrincipal",true,true,wTipoTransicao);
},
function(error) {
alert("download error source " + error.source);
alert("download error target " + error.target);
alert("upload error code" + error.code); },
true, options
);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hamilton Tenório da Silva wrote:
I use this code:
//função para buscar logotipo do cliente no servidor e guardar no aparelho function funBaixaLogotipo(wLogotipo) { var uri = encodeURI(wUrlLogotipo + wLogotipo); var ft = new FileTransfer(); var options = new FileUploadOptions(); var headers={'Authorization':'authHeader'}; ft.download( uri, fileURL, function(entry) { //alert("download complete: " + entry.toURL()); $("#imgLogotipo").attr("src", entry.toURL()); try { if(typeof(window.localStorage) != 'undefined') { window.localStorage.setItem("logotipo", "s"); } else { alert('window.localStorage, not defined'); } } catch(err){ alert('store_local,error,' + err); } $.ui.loadContent("#pagPrincipal",true,true,wTipoTransicao); }, function(error) { alert("download error source " + error.source); alert("download error target " + error.target); alert("upload error code" + error.code); }, true, options ); }
In addition to Hamilton Tenório da Silva code, I think you should add the File Transfer Cordova Plugin to your project
https://github.com/apache/cordova-plugin-file-transfer
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page