示例#1
0
 /**
  * Presaves one attachment for new email 2.0 spec
  * DOES NOT CREATE A NOTE
  * @return string ID of note associated with the attachment
  */
 public function email2saveAttachment()
 {
     $email_uploads = "modules/Emails/{$GLOBALS['current_user']->id}";
     $upload = new UploadFile('email_attachment');
     if (!$upload->confirm_upload()) {
         $err = $upload->get_upload_error();
         if ($err) {
             $GLOBALS['log']->error("Email Attachment could not be attached due to error: {$err}");
         }
         return array();
     }
     $guid = create_guid();
     $fileName = $upload->create_stored_filename();
     $GLOBALS['log']->debug("Email Attachment [{$fileName}]");
     if ($upload->final_move($guid)) {
         copy("upload://{$guid}", sugar_cached("{$email_uploads}/{$guid}"));
         return array('guid' => $guid, 'name' => $GLOBALS['db']->quote($fileName), 'nameForDisplay' => $fileName);
     } else {
         $GLOBALS['log']->debug("Email Attachment [{$fileName}] could not be moved to upload dir");
         return array();
     }
 }
示例#2
0
             }
         }
     }
     $base_filename = urldecode($tempFile);
 } else {
     $upload = new UploadFile('upgrade_zip');
     /* Bug 51722 - Cannot Upload Upgrade File if System Settings Are Not Sufficient, Just Make sure that we can
        upload no matter what, set the default to 60M */
     global $sugar_config;
     $upload_maxsize_backup = $sugar_config['upload_maxsize'];
     $sugar_config['upload_maxsize'] = 60000000;
     /* End Bug 51722 */
     if (!$upload->confirm_upload()) {
         logThis('ERROR: no file uploaded!');
         echo $mod_strings['ERR_UW_NO_FILE_UPLOADED'];
         $error = $upload->get_upload_error();
         // add PHP error if isset
         if ($error) {
             $out = "<b><span class='error'>{$mod_strings['ERR_UW_PHP_FILE_ERRORS'][$error]}</span></b><br />";
         }
     } else {
         $tempFile = "upload://" . $upload->get_stored_file_name();
         if (!$upload->final_move($tempFile)) {
             logThis('ERROR: could not move temporary file to final destination!');
             unlinkUWTempFiles();
             $out = "<b><span class='error'>{$mod_strings['ERR_UW_NOT_VALID_UPLOAD']}</span></b><br />";
         } else {
             logThis('File uploaded to ' . $tempFile);
             $base_filename = urldecode(basename($tempFile));
             $perform = true;
         }