File tree Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change 7
7
8
8
// a valid request has to contain a file to be downloaded
9
9
if (!isset ($ _GET ['file ' ]) || empty ($ _GET ['file ' ])) {
10
- header ('Bad Request ' , true , 400 );
11
- exit ();
10
+ header ('Bad Request ' , true , 400 );
11
+ exit ();
12
12
}
13
13
14
14
// avoid directory traversal vulnerability
20
20
$ filepath = CONFIG_UPLOAD_DIR . '/ ' . $ filename ;
21
21
22
22
if (file_exists ($ filepath )) {
23
- // file exists: return file for download
24
- header ('Content-Type: application/octet-stream ' );
25
- header ('Content-Disposition: attachment; filename=" ' .addslashes ($ filename ).'" ' );
26
- readfile ($ filepath );
23
+ // file exists: return file for download
24
+ header ('Content-Type: application/octet-stream ' );
25
+ header ('Content-Disposition: attachment; filename=" ' .addslashes ($ filename ).'" ' );
26
+ readfile ($ filepath );
27
27
} else {
28
- // file does not exist: 404 Not Found
29
- header ('Not Found ' , true , 404 );
30
- exit ();
28
+ // file does not exist: 404 Not Found
29
+ header ('Not Found ' , true , 404 );
30
+ exit ();
31
31
}
You can’t perform that action at this time.
0 commit comments