source: github/program/steps/mail/upload.inc @ f0f98fb

HEADcourier-fixdev-browser-capabilitiespdorelease-0.6release-0.7release-0.8
Last change on this file since f0f98fb was f0f98fb, checked in by svncommit <devs@…>, 7 years ago

Improvements to Draft handling

  • Property mode set to 100644
File size: 2.5 KB
Line 
1<?php
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                      |
9 | Licensed under the GNU GPL                                            |
10 |                                                                       |
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
23if (!$_SESSION['compose'])
24  {
25  exit;
26  }
27
28
29// create temp dir for file uploads
30$temp_dir = rcmail_create_compose_tempdir();
31
32
33if (!is_array($_SESSION['compose']['attachments']))
34  $_SESSION['compose']['attachments'] = array();
35
36
37$response = '';
38
39foreach ($_FILES['_attachments']['tmp_name'] as $i => $filepath)
40  {
41  $tmpfname = tempnam($temp_dir, 'rcmAttmnt');
42  if (move_uploaded_file($filepath, $tmpfname))
43    {
44    $_SESSION['compose']['attachments'][] = array('name' => $_FILES['_attachments']['name'][$i],
45                                                  'mimetype' => $_FILES['_attachments']['type'][$i],
46                                                  'path' => $tmpfname);
47
48    $button = sprintf('<img src="%s/images/icons/remove-attachment.png" alt="%s" border="0" style="padding-right:2px;vertical-align:middle">', $CONFIG['skin_path'], rcube_label('delete'));
49    $content = sprintf('<a href="#" onclick="%s.command(\\\'remove-attachment\\\',\\\'%s\\\')" title="%s">%s</a>%s',$JS_OBJECT_NAME, $_FILES['_attachments']['name'][$i], rcube_label('delete'), $button, $_FILES['_attachments']['name'][$i]);
50    $response .= sprintf('parent.%s.add2attachment_list(\'%s\',\'%s\');',$JS_OBJECT_NAME, $_FILES['_attachments']['name'][$i], $content);
51    }
52  }
53
54
55// send html page with JS calls as response
56print <<<EOF
57<html>
58<script type="text/javascript">
59if (parent.$JS_OBJECT_NAME)
60{
61$response
62parent.$JS_OBJECT_NAME.show_attachment_form(false);
63parent.$JS_OBJECT_NAME.auto_save_start();
64}
65</script>
66</html>
67EOF;
68exit;
69
70?>
Note: See TracBrowser for help on using the repository browser.