4 +-----------------------------------------------------------------------+
5 | program/steps/mail/upload.inc |
7 | This file is part of the RoundCube Webmail client |
8 | Copyright (C) 2005, RoundCube Dev. - Switzerland |
9 | Licensed under the GNU GPL |
12 | Handle file-upload and make them available as attachments |
14 +-----------------------------------------------------------------------+
15 | Author: Thomas Bruederli <roundcube@gmail.com> |
16 +-----------------------------------------------------------------------+
18 $Id: upload.inc 297 2006-08-06 15:55:11Z thomasb $
23 if (!$_SESSION['compose'])
29 // create temp dir for file uploads
30 $temp_dir = rcmail_create_compose_tempdir();
33 if (!is_array($_SESSION['compose']['attachments']))
34 $_SESSION['compose']['attachments'] = array();
39 foreach ($_FILES['_attachments']['tmp_name'] as $i => $filepath)
41 $tmpfname = tempnam($temp_dir, 'rcmAttmnt');
42 if (move_uploaded_file($filepath, $tmpfname))
44 $id = count($_SESSION['compose']['attachments']);
45 $_SESSION['compose']['attachments'][] = array('name' => $_FILES['_attachments']['name'][$i],
46 'mimetype' => $_FILES['_attachments']['type'][$i],
49 if (is_file($CONFIG['skin_path'] . '/images/icons/remove-attachment.png'))
50 $button = sprintf('<img src="%s/images/icons/remove-attachment.png" alt="%s" border="0" style="padding-right:2px;vertical-align:middle" />',
52 rcube_label('delete'));
54 $button = rcube_label('delete');
56 $content = sprintf('<a href="#delete" onclick="return %s.command(\\\'remove-attachment\\\', \\\'rcmfile%d\\\', this)" title="%s">%s</a>%s',
59 rcube_label('delete'),
61 rep_specialchars_output($_FILES['_attachments']['name'][$i], 'js'));
63 $response .= sprintf('parent.%s.add2attachment_list(\'rcmfile%d\',\'%s\');',
71 // send html page with JS calls as response
74 parent.$JS_OBJECT_NAME.show_attachment_form(false);
75 parent.$JS_OBJECT_NAME.auto_save_start();
78 rcube_iframe_response($frameout);