Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions imageDownload.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
<?php
$file = $_REQUEST['imageUrl'];
if(!$file){
// File doesn't exist, output error
die('file not found');
}else{
// Set headers
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=$file");
header("Content-Type: image/gif");
header("Content-Transfer-Encoding: binary");
// Read the file from disk
readfile($file);

//Check the scheme ://, http:// or https:// followed by a valid hostname name start
$validHTTPURLBegin = '/^(:|http(s?):)\/\/[\w]+/';
if (!preg_match($validHTTPURLBegin, $file)) {
die('File is not a valid URL');
}

// Set headers
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=$file");
header("Content-Type: image/gif");
header("Content-Transfer-Encoding: binary");
// Read the file from disk
readfile($file);

?>