/
send_file.php
27 lines (22 loc) · 954 Bytes
/
send_file.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
// Let's try an alternative way of getting the GET params
foreach ( array('gallery', 'dirkey', 'filekey', 'mode') as $getkey ){
if ( isset($_GET[$getkey]) ) $$getkey = $_GET[$getkey];
}
send_file($gallery,$dirkey,$filekey,$mode);
function send_file($gallery,$dirkey,$filekey,$mode){
// Send a file using it's own mime type, useful for sending image files
// without using the resampling code, or sending movie or other files.
// Set the mode to "Attach" to tell the browser to download rather than open the file
include("set_paths.php");
include("$imagedata/$gallery");
include_once('generate_filelist.php');
$filelist = generate_filelist($gallery,$dirkey);
$file = $filelist[$filekey];
$mimetype=mime_content_type($file);
header('Content-Type: '.$mimetype);
if( $mode == 'attach' ) header('Content-disposition: attachment; filename="'.basename($file) .'"');
readfile($dirs[$dirkey] ."/$file");
}
////////////////
?>