When I click on my preview button it downloads my file But I only want to be able to force download when I click on the path link in the foreach loop on view.
Question how can I force download when I click on a link in my foreach loop on view. Currently when I click on my preview button it downloads link which is wrong.
<div class="row"> <?php foreach ($attachments as $attachment) {?> <div class="col-lg-2 col-md-2 col-sm-2 col-xs-12"> <!-- Click link below to download.--> <a class="<?php echo $attachment['path'];?>"><?php echo $attachment['file_name'];?></a> </div> <?php }?> </div>
</div> </div>
Controller
PHP Code:
<?php
class Preview extends MX_Controller {
public function __construct() { parent::__construct(); $this->load->library('parsedown'); $this->parsedown->setLiteralBreaks(true); $this->load->helper('download'); }