Forum Academy Marketplace Showcase Pricing Features

How to download a picture saved in database

Hello

I have users uploading their pictures and saved in the database. How I can download a picture from the database ?

Thanks

Hello @abalgir, :slight_smile: Usually, we’re able to download files using a link element. However, since it’s a picture - using a link element will just open the image in a new tab. In order to download a saved image on-click, I think you would need to use an HTML element. If you have a Download Icon, place an HTML element over the icon with the following code (starting with ‘<’ and ending with ‘>’):

a href=“CurrentPageUser’sProfilePicture’sURL” download=“CurrentPageUser’sFirstName”>Download</a

In this example, we’re downloading the Current Page User’s profile picture, and setting the name of that downloaded image to be that User’s first name.

Then group the HTML element and the download icon together in a group that is fixed-width, making sure the HTML element is in front. That should keep everything together, and will download the image on-click. :slight_smile:

2 Likes

Many thanks Fay. I will try it. I tried the link, it was not a clean way :wink:

Right, HTML should do it! No problem :slight_smile:

Sorry Fay, but how to make the HTML element clickable? It is my first time using this type of element.
Regards

My apologies, it looks like the entire element won’t be clickable. You would have to include a word for the link, such as ‘Download’. Making it:

a href=“CurrentPageUser’sProfilePicture’sURL” download=“CurrentPageUser’sFirstName”>Download</a

I’ll keep looking to see if there’s a different way to make the entire element clickable, so there wouldn’t be any text.

Not to worry :wink: it worked with the DOWNLOAD word. It is a better solution than a link :wink: many thanks

1 Like

Ok great! My pleasure :slight_smile:

I had to add “http:” between href and CurrentFile’s URL for this to work.

meaning that the working link looks like:
<a href=http:"CurrentFile's URL" download> Download </a>

This topic was automatically closed after 70 days. New replies are no longer allowed.