-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
68 lines (55 loc) · 1.66 KB
/
index.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
66
67
68
<?php
function mail_file($to, $from, $subject, $body, $file){
$boundary = md5(rand());
$headers = array(
'MIME-Version: 1.0',
"Content-Type: multipart/mixed; boundary=\"{$boundary}\"",
"From: {$from}"
);
$message = array(
"--{$boundary}",
'Content-Type: text/plain',
'Content-Transfer-Encoding: 7bit',
'',
chunk_split($body),
"--{$boundary}",
"Content-Type: {$file['type']}; name=\"{$file['name']}\"",
"Content-Disposition: attachment; filename=\"{$file['name']}\"",
"Content-Transfer-Encoding: base64",
'',
chunk_split(base64_encode(file_get_contents($file['tmp_name']))),
"--{$boundary}--"
);
mail($to, $subject, implode("\r\n", $message), implode("\r\n", $headers));
}
if (isset($_POST['name'], $_FILES['file'])) {
$body = " From: {$_POST['name']} " . "
Details:
Name: {$_FILES['file']['name']}
Size: {$_FILES['file']['size']}
Type: {$_FILES['file']['type']} "
;
mail_file('<YOUR REPCIPIENT HERE>', '<YOUR EMAIL HERE>', '<SUBJECT NAME>', $body, $_FILES['file']);
}
?>
<!DOCTYPE html>
<html>
<head>
<title>email form</title>
</head>
<body>
<form action="" method="post" enctype="multipart/form-data">
<p>
<label for="name">Name</label>
<input type="text" name="name" id="name">
</p>
<p>
<label for="file">file</label>
<input type="file" name="file" id="file">
</p>
<p>
<input type="submit" value="Email File" />
</p>
</form>
</body>
</html>