-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexport-tree.php
More file actions
26 lines (22 loc) · 787 Bytes
/
export-tree.php
File metadata and controls
26 lines (22 loc) · 787 Bytes
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
<?php
/**
##file_doc
@title Export Tree
@description This is a script which takes a string identifying the type of file to export, and a filename to use. It returns a link to the generated file.
##end
**/
$type = $_POST['type'];
$fname = $_POST['fname'];
if ($type == 'bracket-file') {
$file = fopen($_SERVER['DOCUMENT_ROOT'] . "/temp/$fname.txt", "w");
fwrite($file, $_POST['brackets']);
fclose($file);
$link = "<a href='/temp/$fname.txt' download='' id='temp-file-download'></a>";
echo $link;
} elseif ($type == 'tree-file') {
$file = fopen($_SERVER['DOCUMENT_ROOT'] . "/temp/$fname.tree", "w");
fwrite($file, $_POST['treestring']);
fclose($file);
$link = "<a href='/temp/$fname.tree' download='' id='temp-file-download'></a>";
echo $link;
}