-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocess.php
65 lines (59 loc) · 1.56 KB
/
process.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/**
* Note: This is purely an example script. It will not do a whole lot and probably won't suit your needs.
* Please keep in mind that if you allow certain types of files to be uploaded to your server you could create a security risk.
* Take note of the switches below that check file types.
*/
// CHANGE THIS ACCORDINGLY
$target_path = "temp/";
$myFile = $target_path."post_data.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, "Title: ".$_POST['title']."\n");
fwrite($fh, "Another Field: ".$_POST['testdata']."\n");
fclose($fh);
$uploads_dir = $target_path;
if(count($_FILES["Filedata"]["error"]) < 2) {
// Single file
$tmp_name = $_FILES["Filedata"]["tmp_name"];
$name = $_FILES["Filedata"]["name"];
$ext = substr(strrchr($name, '.'), 1);
switch(strtolower($ext)) {
case 'jpg':
case 'jpeg':
case 'png':
case 'gif':
case 'png':
case 'doc':
case 'txt':
move_uploaded_file($tmp_name, "$uploads_dir/$name");
break;
default:
exit();
break;
}
} else {
// Multiple files
foreach ($_FILES["Filedata"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $_FILES["Filedata"]["tmp_name"][$key];
$name = $_FILES["Filedata"]["name"][$key];
$ext = substr(strrchr($name, '.'), 1);
switch(strtolower($ext)) {
case 'jpg':
case 'jpeg':
case 'png':
case 'gif':
case 'png':
case 'doc':
case 'txt':
move_uploaded_file($tmp_name, "$uploads_dir/$name");
break;
default:
exit();
break;
}
}
}
}
echo 'RETURN DATA!';
?>