Repository navigation
Expand file tree
/
Copy pathsubmit.php
More file actions
54 lines (44 loc) · 1.34 KB
/
Copy pathsubmit.php
File metadata and controls
54 lines (44 loc) · 1.34 KB
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
45
46
47
48
49
50
51
52
53
54
<?php
/* this test script saves a drawing in existing folder ./img */
if( ($_SERVER['REQUEST_METHOD'] !== 'POST') )
{
print "error";
exit;
}
$title = trim($_POST["title"]);
$category = "other";
if($_POST["category"]) $category = $_POST["category"];
if (isset($_FILES['Filedata2']))
{
if(empty($_FILES['Filedata2']['tmp_name']))
{
die("error&message=upload failed");
}
$t = time();
$new = "img/".$category;
$tt=preg_replace("/[^a-zA-Z0-9_ ]/" , "" , $title);
$tt = preg_replace("/ /", "_", $tt);
$destination = $new."/".$t."_".$tt.".jpg";
if(!file_exists($new))
{
if (!mkdir($new, 0755, true))
{
//die('error');
}
}
$destination_qky = "./img/source.qky"; /* path to store qky */
if (isset($_FILES['Filedata'])) /* try to upload .qky if available*/
{
@move_uploaded_file($_FILES['Filedata']['tmp_name'], $destination_qky);
}
/* try to upload the final JPG */
if(move_uploaded_file($_FILES['Filedata2']['tmp_name'], $destination))
{
print "done=ok&message=Drawing has been saved to SpeedPaint gallery. You will be redirected in a few seconds ...&redirect=http://www.speedpaint.info/queeky/gallery.php"; /* notify tha app that saving succeed */
} else {
die("error&message=upload failed");
}
} else {
die("error");
}
?>