-
Notifications
You must be signed in to change notification settings - Fork 0
/
toascii.php
44 lines (34 loc) · 1.05 KB
/
toascii.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
43
44
<!DOCTYPE html>
<html>
<body>
<style>
.font1{
font-family: monospace;
}
</style>
<?php
$directory = "images/";
$target_file = $directory.basename($_FILES["select_file"]["name"]);
if(isset($_POST["submit"])) {
if (move_uploaded_file($_FILES["select_file"]["tmp_name"], $target_file)) {
$name = $_FILES["select_file"]["name"];
$scale = $_POST["scale"];
if(isset($_POST["background"])){
$background = $_POST["background"];
}
else{
$background = "black";
}
$to_ascii = shell_exec("python toAscii.py False $name $background $scale");
//filter out everything at the start until we meet one of these characters: '@', '%', '#', '&', '=', '+', '-', ':', ',', '.'
$to_ascii = preg_replace("/^shape: [^\@\%\&\=\+\-\:\.\#]*/", "", $to_ascii);
$result = preg_replace("/>/", "<br>", $to_ascii);
echo "<label for='result' class='font1'> $result </label>";
}
}
else{
echo "Did not submit. Please attempt again";
}
?>
</body>
</html>