0
$select_pic  = "SELECT pic.photo_link,od.* from orders as od inner join photo as pic ON pic.user_id = od.user_id WHERE od.id = '".$orderid."'";
$pic = $common->select_inner($select_pic);
foreach($pic as $photo){
}

I am getting images from this in $photo['photo_link']; I want to download picture on click of download button how can i do this using php or javascript.

<a download="<?php echo $photo['photo_link']; ?>"  title="ImageName">
<img alt="ImageName" src="uploads/category/<?php echo $photo['photo_link']; ?>">
</a>

I have tried this but its not working

shikha
  • 19
  • 1
  • 6

2 Answers2

1

You are missing href attribute in tag.

I have checked with below code working:

<a href="" download="<?php echo $photo['photo_link']; ?>"  title="ImageName">
<img alt="ImageName" src="uploads/category/<?php echo $photo['photo_link']; ?>">
</a>

Please see following link for your reference: href image link download on click

Patrick R
  • 6,621
  • 1
  • 24
  • 27
-1

Try this code

<a href="uploads/category/<?php echo $photo['photo_link']; ?" download>
    <button>Download</button>
</a>