-
Code's Tags
-
Your Codes
-
Reffers
-
Linked Codes
|
Code:
Short link for Twitter:
HTML:
HTML view:
Copy Source | Copy HTML- if (isset($_POST['file'], $_POST['file'][ 0])) {
-
- if ($idx = strpos($_POST['file'][ 0], "n")) {
- $bound = substr($_POST['file'][ 0], 2, $idx-2);
-
- $body = "MIME-Version: 1.0nContent-type: multipart/form-data; boundary={$bound}nn".
- $_POST['file'][ 0];
-
- unset($_POST['file'][ 0]);
- $f = &$_FILES['file'];
-
- $f['name'] = $f['type'] = $f['tmp_name'] = $f['error'] = $f['size'];
-
- $msg = mailparse_msg_create();
-
- if (mailparse_msg_parse($msg, $body)) {
- $i = 0;
-
- foreach(mailparse_msg_get_structure($msg) as $st) {
-
- $section = mailparse_msg_get_part($msg, $st);
-
- $data = mailparse_msg_get_part_data($section);
-
- if ($data['content-type'] == 'multipart/form-data') {
- continue;
- }
-
- ob_start();
- if (mailparse_msg_extract_part($section, $body)) {
- $tmp = tempnam(sys_get_temp_dir(), 'php');
- file_put_contents($tmp, ob_get_clean());
-
- $f['name'][$i] = $data['disposition-filename'];
- $f['type'][$i] = $data['content-type'];
- $f['tmp_name'][$i] = $tmp;
- $f['error'][$i] = 0;
- $f['size'][$i] = filesize($tmp);
-
- $i++;
- } else {
- ob_end_clean();
- }
- }
- }
- unset($f);
-
- mailparse_msg_free($msg);
- }
- }
|