forked from hydroshare/hydroshare_drupal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexport.php
34 lines (28 loc) · 910 Bytes
/
export.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
<?php
require 'data_model_file_ops.php';
$path = $_GET["file"];
// =-=-=-=-=-=-=-
// zip the data model directory to export it to
// the user per the request
if( !data_model_zip_dir( $path ) ) {
error_log( "export.php - error in creating archive file for [$path]" );
return;
}
if (file_exists($path)) {
// =-=-=-=-=-=-=-
// set up a file transfer for the zip file
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . basename($path));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($path));
ob_clean();
flush();
readfile($path);
// =-=-=-=-=-=-=-
// clean up the zip ( duplicate data )
unlink( $path );
}