Software Archive
Read-only legacy content
17061 Discussions

Download an image to device

David_R_7
Beginner
640 Views

Hello,

i´m creating an image gallery with "lightgallery", everything is correct except the download button that do nothing.

I´m trying flietransfer and file plugins but i´m doing something wrong.

I there any easy way to make a button to download images from the gallery i´ve created to the device?

0 Kudos
1 Solution
Hamilton_Tenório_da_
Valued Contributor I
640 Views

David,

I am using File Transfer with success. See my code:

var ft = new FileTransfer(); 
var options = new FileUploadOptions(); 
var headers={'Authorization':'authHeader'}; 
ft.download( uri, fileURL + CNome, function(entry) {    //CNome is the name of my file
      $("#imgImagemEvento").attr("src", entry.toURL() + "/" & CNome );
      $('#divImagemEvento').show();
}, 
function(error) { 
      alert("download error source " + error.source); 
      alert("download error target " + error.target); 
      alert("upload error code" + error.code); },
true, options
); 

Try it.

Hamilton

View solution in original post

0 Kudos
5 Replies
Hamilton_Tenório_da_
Valued Contributor I
641 Views

David,

I am using File Transfer with success. See my code:

var ft = new FileTransfer(); 
var options = new FileUploadOptions(); 
var headers={'Authorization':'authHeader'}; 
ft.download( uri, fileURL + CNome, function(entry) {    //CNome is the name of my file
      $("#imgImagemEvento").attr("src", entry.toURL() + "/" & CNome );
      $('#divImagemEvento').show();
}, 
function(error) { 
      alert("download error source " + error.source); 
      alert("download error target " + error.target); 
      alert("upload error code" + error.code); },
true, options
); 

Try it.

Hamilton

0 Kudos
David_R_7
Beginner
640 Views

Hi Hamilton,

Thanks a lot for your help :)

 

0 Kudos
Hamilton_Tenório_da_
Valued Contributor I
640 Views

David> yes, the CNome is my variable with the file name. You can use any name to this variable or even put the name directly ( + "/yourFileName")

Hamilton

0 Kudos
David_R_7
Beginner
640 Views

Thanks Hamilton,

I´m going crazy, i´m not sure what i´m doing wrong.... can i send you my project and check it?

0 Kudos
Hamilton_Tenório_da_
Valued Contributor I
640 Views

David,

I can try. Send me in private.

Hamilton

0 Kudos
Reply