Force uploaded image to download when link is clicked.

2 posts by 2 authors in: Forums > CMS Builder
Last Post: June 20, 2011   (RSS)

Re: [zick] Force uploaded image to download when link is clicked.

By robin - June 20, 2011

Hey zick,

If you want to force a download you'll need to use an intermediate script that sends the download headers to the browser. You can pass the image num as a parameter to the script so it knows what file to send.

Here is a good php function to use and some examples:
http://php.net/manual/en/function.readfile.php

Your Download link might look like:
<?php foreach ($galleryRecord['gallery'] as $upload): ?>
<a href="downlaod.php?num=<?php echo $upload['num'] ?>">Download Photo<?php echo $upload['info1'] ?></a>
<?php endforeach ?>


Hope that helps,
Robin
Robin
Programmer
interactivetools.com