[Resolved] X-Litespeed-Location Implementation

Status
Not open for further replies.

sahith

Well-Known Member
#1
I have a image download script which used to force download a image via browser "Save As" when user click a particular resolution with the following code

Code:
header("Content-Length: " . filesize($file));
header("Content-Disposition: attachment; filename=" . basename($_GET['query']));
header('Content-Transfer-Encoding: binary');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
But i wanted to implement X-Litespeed-Location through which user should be able to download it directly from static file. But developer told it is not possible to implement force download along with X-Litespeed-Location, he used following code

header('X-LiteSpeed-Location: ' . ltrim($file, '.'));

Now images are opening in browser without any force download. Please guide me to make image force download along with X-Litespeed-Location. so i can explain my developer.
 
Last edited by a moderator:

NiteWave

Administrator
#2
I tried out an workaround for you. here's the example php code:
PHP:
/usr/local/lsws/DEFAULT/html/test>cat t.php
<?php
$file = "lsws_logo.png";
header("Content-Length: " . filesize($file));
//header("Content-Disposition: attachment; filename=" . basename($_GET['query']));
header("Content-Disposition: attachment; filename=logo.png");
header('Content-Transfer-Encoding: binary');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header("Content-Type: binary/data");

//header('X-LiteSpeed-Location: ' . ltrim($file, '.'));
header('X-LiteSpeed-Location: /test/lsws_logo.png?just_download_it');
?>
plus the .htaccess:
Code:
/usr/local/lsws/DEFAULT/html/test>cat .htaccess
RewriteEngine On
RewriteCond %{QUERY_STRING} just_download_it
RewriteRule .* - [T=binary/data]
when I access http://IP:8088/test/t.php, Chrome pop up to download logo.png
 
Last edited by a moderator:
Status
Not open for further replies.
Top