forked from DarinPhillips/people-prodigy
/
download.php
63 lines (45 loc) · 1.12 KB
/
download.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?
//include_once("session.php");
include_once("includes/database.class");
include_once("includes/common.class");
$db_object=new database();
$common=new common();
class download
{
function download_file($db_object,$common,$user_id,$load)
{
$path=$common->path;
$external=$common->prefix_table("external");
$sql="select $load from $external where user_id='$user_id'";
//echo $sql;exit;
$sql_res=$db_object->get_single_column($sql);
$filename=$sql_res[0];
$file = $path."uploads/externalcandidate/$load/$filename";
if(file_exists($file))
{
$len = filesize($file);
$filename =$load."_".$filename;
header("content-type: application/stream");
header("content-length: $len");
header("content-disposition: attachment; filename=$filename");
$fp=fopen($file,"r");
fpassthru($fp);
exit;
}
else
{
$str=<<<EOD
<script>
alert( '$err[cEmptyrecords]' );
window.location=document.referrer;
</script>
EOD;
//echo $str;
}
}
}//end class
$ob = new download;
$user_id=$_GET["user_id"];
$load=$_GET["load"];
$ob->download_file($db_object,$common,$user_id,$load);
?>