php - How to download image file by force download -
i trying download image file in ci getting error when open download image file. need :(
$file_name = $_get['file_name']; $file_path = "./ups_printimages/".$file_name; if(file_exists($file_path)) { $this->load->helper('download'); $data = file_get_contents($file_path); // read file's contents $name = 'ups_label.png'; force_download($name, $data); } else { echo "file not exist"; }
use header force download. use code below
$file_name = $_get['file_name']; $file_path = "./ups_printimages/".$file_name; if(file_exists($file_path)) { header('content-type: image/jpeg'); header("content-transfer-encoding: binary"); header("content-disposition: attachment; filename=\"" . basename($file_name) . "\""); readfile($file_path); } else { echo "file not exist"; }
hope helps yoiu
Comments
Post a Comment