php - prestashop display attachment inline -
i'm creating custom pdf file containing product details. display product attachments images. have changed attachment controller
header('content-disposition: inline; filename="'.utf8_decode($a->file_name).'"');
when visit url through browser displays nicely:
http://domain.nl/nl/index.php?controller=attachment&id_attachment=483
but using url inside img tag in pdf template gives:
tcpdf error: [image] unable image: http://domain.nl/nl/index.php?controller=attachment&id_attachment=483
does have idea on how make work?
i created new file next attachmentcontroller.php called attachmentinlinecontroller.php. contents different:
<?php class attachmentinlinecontrollercore extends frontcontroller { public function __construct() { $a = new attachment(tools::getvalue('id_attachment'), $this->context->language->id); if (!$a->id) { tools::redirect('index.php'); } if (ob_get_level() && ob_get_length() > 0) { ob_end_clean(); } header('content-transfer-encoding: binary'); header('content-type: '.$a->mime); header('content-length: '.filesize(_ps_download_dir_.$a->file)); header('content-disposition: inline; filename="'.utf8_decode($a->file_name).'"'); @set_time_limit(0); readfile(_ps_download_dir_.$a->file); exit; } }?>
i removed hook, changed content-disposition inline, , changed function postprocess()
__construct
. if use:
http://domain.nl/nl/index.php?controller=attachmentinline&id_attachment=483
it display attachment inline, , can use url in image tags etc.
Comments
Post a Comment