Changeset 569701d in github


Ignore:
Timestamp:
Mar 17, 2011 10:17:08 AM (2 years ago)
Author:
alecpl <alec@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
a8317ef
Parents:
32b11d3
Message:
  • Handle properly situation when uploaded attachment file is too big
File:
1 edited

Legend:

Unmodified
Added
Removed
  • program/steps/mail/attachments.inc

    r4591de7 r569701d  
    8484if (is_array($_FILES['_attachments']['tmp_name'])) { 
    8585  foreach ($_FILES['_attachments']['tmp_name'] as $i => $filepath) { 
    86     $attachment = array( 
    87       'path' => $filepath, 
    88       'size' => $_FILES['_attachments']['size'][$i], 
    89       'name' => $_FILES['_attachments']['name'][$i], 
    90       'mimetype' => rc_mime_content_type($filepath, $_FILES['_attachments']['name'][$i], $_FILES['_attachments']['type'][$i]), 
    91       'group' => $COMPOSE_ID, 
    92     ); 
     86    // Process uploaded attachment if there is no error 
     87    $err = $_FILES['_attachments']['error'][$i]; 
    9388 
    94     $attachment = $RCMAIL->plugins->exec_hook('attachment_upload', $attachment); 
     89    if (!$err) { 
     90      $attachment = array( 
     91        'path' => $filepath, 
     92        'size' => $_FILES['_attachments']['size'][$i], 
     93        'name' => $_FILES['_attachments']['name'][$i], 
     94        'mimetype' => rc_mime_content_type($filepath, $_FILES['_attachments']['name'][$i], $_FILES['_attachments']['type'][$i]), 
     95        'group' => $COMPOSE_ID, 
     96      ); 
    9597 
    96     if ($attachment['status'] && !$attachment['abort']) { 
     98      $attachment = $RCMAIL->plugins->exec_hook('attachment_upload', $attachment); 
     99    } 
     100 
     101    if (!$err && $attachment['status'] && !$attachment['abort']) { 
    97102      $id = $attachment['id']; 
    98        
     103 
    99104      // store new attachment in session 
    100105      unset($attachment['status'], $attachment['abort']); 
    101106      $_SESSION['compose']['attachments'][$id] = $attachment; 
    102        
     107 
    103108      if (($icon = $_SESSION['compose']['deleteicon']) && is_file($icon)) { 
    104109        $button = html::img(array( 
     
    118123 
    119124      $content .= Q($attachment['name']); 
    120        
     125 
    121126      $OUTPUT->command('add2attachment_list', "rcmfile$id", array( 
    122127        'html' => $content, 
     
    126131    } 
    127132    else {  // upload failed 
    128       $err = $_FILES['_attachments']['error'][$i]; 
    129133      if ($err == UPLOAD_ERR_INI_SIZE || $err == UPLOAD_ERR_FORM_SIZE) { 
    130134        $msg = rcube_label(array('name' => 'filesizeerror', 'vars' => array('size' => show_bytes(parse_bytes(ini_get('upload_max_filesize')))))); 
     
    136140        $msg = rcube_label('fileuploaderror'); 
    137141      } 
    138      
     142 
    139143      $OUTPUT->command('display_message', $msg, 'error'); 
    140144      $OUTPUT->command('remove_from_attachment_list', $uploadid); 
Note: See TracChangeset for help on using the changeset viewer.