-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsaveSVG.php
More file actions
32 lines (29 loc) · 797 Bytes
/
saveSVG.php
File metadata and controls
32 lines (29 loc) · 797 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
27
28
29
30
31
32
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// collect value of input field
$SVGdatoteka = $_POST['svgFile'];
if (empty($SVGdatoteka)) {
echo "Name is empty";
} else {
$path = "results";
# poisci sliko z najvecjo stevilko
if ($handle = opendir($path)) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
if(!is_dir($entry)){
$myFile[] = substr($entry,0,strrpos($entry, "."));
}
}
}
closedir($handle);
}
rsort($myFile,SORT_NUMERIC);
$nextFileNumber = $myFile[0]+1;
# zapisi datoteko
$pathNewFile = $path.'/'.$nextFileNumber.'.svg';
$newFile = fopen($pathNewFile, "w") or die("Unable to open file!");
fwrite($newFile, $SVGdatoteka);
fclose($newFile);
}
}
?>