commit | author | age
|
4e17e6
|
1 |
<?php |
T |
2 |
|
|
3 |
/* |
|
4 |
+-----------------------------------------------------------------------+ |
|
5 |
| program/steps/mail/upload.inc | |
|
6 |
| | |
|
7 |
| This file is part of the RoundCube Webmail client | |
|
8 |
| Copyright (C) 2005, RoundCube Dev. - Switzerland | |
30233b
|
9 |
| Licensed under the GNU GPL | |
4e17e6
|
10 |
| | |
T |
11 |
| PURPOSE: | |
|
12 |
| Handle file-upload and make them available as attachments | |
|
13 |
| | |
|
14 |
+-----------------------------------------------------------------------+ |
|
15 |
| Author: Thomas Bruederli <roundcube@gmail.com> | |
|
16 |
+-----------------------------------------------------------------------+ |
|
17 |
|
|
18 |
$Id$ |
|
19 |
|
|
20 |
*/ |
|
21 |
|
|
22 |
|
|
23 |
if (!$_SESSION['compose']) |
|
24 |
{ |
|
25 |
exit; |
|
26 |
} |
|
27 |
|
|
28 |
|
70d4b9
|
29 |
// use common temp dir for file uploads |
T |
30 |
$temp_dir = unslashify($CONFIG['temp_dir']); |
597170
|
31 |
|
4e17e6
|
32 |
|
T |
33 |
if (!is_array($_SESSION['compose']['attachments'])) |
|
34 |
$_SESSION['compose']['attachments'] = array(); |
|
35 |
|
|
36 |
|
|
37 |
$response = ''; |
|
38 |
|
|
39 |
foreach ($_FILES['_attachments']['tmp_name'] as $i => $filepath) |
|
40 |
{ |
|
41 |
$tmpfname = tempnam($temp_dir, 'rcmAttmnt'); |
15a9d1
|
42 |
if (move_uploaded_file($filepath, $tmpfname)) |
4e17e6
|
43 |
{ |
aade7b
|
44 |
$id = count($_SESSION['compose']['attachments']); |
4e17e6
|
45 |
$_SESSION['compose']['attachments'][] = array('name' => $_FILES['_attachments']['name'][$i], |
T |
46 |
'mimetype' => $_FILES['_attachments']['type'][$i], |
|
47 |
'path' => $tmpfname); |
|
48 |
|
aade7b
|
49 |
if (is_file($CONFIG['skin_path'] . '/images/icons/remove-attachment.png')) |
T |
50 |
$button = sprintf('<img src="%s/images/icons/remove-attachment.png" alt="%s" border="0" style="padding-right:2px;vertical-align:middle" />', |
|
51 |
$CONFIG['skin_path'], |
|
52 |
rcube_label('delete')); |
|
53 |
else |
|
54 |
$button = rcube_label('delete'); |
|
55 |
|
|
56 |
$content = sprintf('<a href="#delete" onclick="return %s.command(\\\'remove-attachment\\\', \\\'rcmfile%d\\\', this)" title="%s">%s</a>%s', |
|
57 |
$JS_OBJECT_NAME, |
|
58 |
$id, |
|
59 |
rcube_label('delete'), |
|
60 |
$button, |
|
61 |
rep_specialchars_output($_FILES['_attachments']['name'][$i], 'js')); |
|
62 |
|
|
63 |
$response .= sprintf('parent.%s.add2attachment_list(\'rcmfile%d\',\'%s\');', |
|
64 |
$JS_OBJECT_NAME, |
|
65 |
$id, |
|
66 |
$content); |
4e17e6
|
67 |
} |
T |
68 |
} |
|
69 |
|
|
70 |
|
|
71 |
// send html page with JS calls as response |
41fa0b
|
72 |
$frameout = <<<EOF |
4e17e6
|
73 |
$response |
T |
74 |
parent.$JS_OBJECT_NAME.show_attachment_form(false); |
f0f98f
|
75 |
parent.$JS_OBJECT_NAME.auto_save_start(); |
4e17e6
|
76 |
EOF; |
41fa0b
|
77 |
|
T |
78 |
rcube_iframe_response($frameout); |
4e17e6
|
79 |
|
a894ba
|
80 |
?> |