-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsaveRvState.php
43 lines (31 loc) · 977 Bytes
/
saveRvState.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
<?php
header('Content-Description: File Transfer');
header('Content-type: application/zip');
header('Content-Transfer-Encoding: binary');
header("Pragma: public");
ob_start();
$data = $_POST['content'];
$seed = rand();
$file = "/var/tmp/tmp" . $_SERVER['REQUEST_TIME'] . "_" . $seed;
$fp = fopen($file . ".rvs.txt", "w") or die("Couldn't open $file for writing!");
fwrite($fp, $data) or die("Couldn't write values to file!");
fclose($fp);
// Prepare File
$file2 = tempnam("/var/tmp", "zip");
$zip = new ZipArchive();
$zip->open($file2, ZipArchive::OVERWRITE);
$filenamesend = $_POST['datasetname'];
// Staff with content
$zip->addFile($file . ".rvs.txt", $filenamesend . '.rvs.txt');
// Close and send to users
$zip->close();
sleep(4);
$length_file = filesize($file2);
header('Content-Length: ' . $length_file);
header('Content-Disposition: attachment; filename="' . $filenamesend . '.zip"');
readfile($file2);
//ob_clean();
//flush();
//unlink($file2);
exit;
?>