New and updated version of old code.
This commit is contained in:
26
api/imageDownload.php
Normal file
26
api/imageDownload.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
if (isset($_GET['filename']))
|
||||
{
|
||||
require("../include/appConfig.php");
|
||||
|
||||
// Strip only file name form user string so he do not download system configs or whatnot
|
||||
$file = $appConfig['imagesLocation'].basename($_GET['filename']);
|
||||
|
||||
if(!file_exists($file)) die('404 - File not found.');
|
||||
else
|
||||
{
|
||||
// Set appropriate headers
|
||||
header("Cache-Control: private");
|
||||
header("Content-Description: File Transfer");
|
||||
header("Content-Disposition: attachment; filename=".basename($_GET['filename']));
|
||||
header("Content-Type: ".mime_content_type($file));
|
||||
header("Content-Transfer-Encoding: binary");
|
||||
|
||||
// Read the file from disk
|
||||
readfile($file);
|
||||
}
|
||||
}
|
||||
else echo "404 - File name not found.";
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user