Roundcube Community Forum

News and Announcements => General Discussion => Topic started by: laurisnet on April 01, 2009, 02:20:31 PM

Title: Custom file upload...
Post by: laurisnet on April 01, 2009, 02:20:31 PM
Hello,

I have made custom upload form for file upload and when file is uploaded it execute some other file not attachment.inc.

So my question is following:

How i can get in my upload script (upload.php) to return roundcube varialbes and sessions such as:
$RCMAIL->user->get_username();

$_SESSION['compose'];

Thanks.
Title: Custom file upload...
Post by: rosali on April 02, 2009, 01:06:28 AM
Either you disable database managed session (see sessions.inc) of you access your custom upload form by including it in index.php.
Title: Custom file upload...
Post by: laurisnet on April 02, 2009, 07:47:41 AM
Ok, i fixed my problem, there is another problem :)

With whitch commands i can add and remove attachemnt from mail content?

If i am not mistaking then i have to check this:


$id = count($_SESSION['compose']['attachments']);
      $_SESSION['compose']['attachments'][] = array(
        'name' => $_FILES['_attachments']['name'][$i],
        'mimetype' => rc_mime_content_type($tmpfname, $_FILES['_attachments']['type'][$i]),
        'path' => $tmpfname,
      );

      if (is_file($icon = $CONFIG['skin_path'] . '/images/icons/remove-attachment.png')) {
        $button = html::img(array(
          'src' => $icon,
          'alt' => rcube_label('delete'),
          'style' => "padding-right:2px;vertical-align:middle",
        ));
      }
      else {
        $button = Q(rcube_label('delete'));
      }

      $content = html::a(array(
        'href' => "#delete",
        'onclick' => sprintf("return %s.command('remove-attachment','rcmfile%d', this)", JS_OBJECT_NAME, $id),
        'title' => rcube_label('delete'),
      ), $button);
     
      $content .= Q($_FILES['_attachments']['name'][$i]);


in attachment.inc
Title: Custom file upload...
Post by: laurisnet on April 02, 2009, 07:51:32 AM
I am not including my upload.php file in index.php, but i can get response from this file, what js response i need for rcube?

thanks
Title: Custom file upload...
Post by: laurisnet on April 02, 2009, 08:55:06 AM
I guess i have to add all necesarry to this $_SESSION['compose']['attachments'][];

Right?
Title: Custom file upload...
Post by: rosali on April 02, 2009, 09:14:29 AM
I do not have the whole Roundcube code in mind. But I remember that I have used this session array when coding my forward as attachment plugin.
Title: Custom file upload...
Post by: laurisnet on April 02, 2009, 09:38:11 AM
CAn you tell me, is this session array created at the moment i made upload or its created before i upload file?
Title: Custom file upload...
Post by: rosali on April 02, 2009, 11:18:35 AM
The upload creates a $_FILES array. Uploads do not touch the $_SESSION array() automatically.
Title: Custom file upload...
Post by: laurisnet on April 02, 2009, 12:35:28 PM
ok with print_r($_SESSION); i get empty array.
What exacly i need to post back after upload completes?

And what is in this:
$_SESSION['compose']['attachments'];
and
rc_mime_content_type();

its used in attachment.inc file!

Mime tipe is not that much important at the moment, but what is in this $_SESSION['compose']['attachments'] thats interesting :)

thanks
Title: Custom file upload...
Post by: rosali on April 02, 2009, 12:49:25 PM
As already mentioned RoundCube $_SESSION is only available if script is included in index.php by using appropriate task and action. An alternative is to disable RoundCube's database managed sessions by hacking sessions.inc.

OK, I'm off this thread.
Title: Custom file upload...
Post by: laurisnet on April 02, 2009, 02:10:20 PM
ok thanks anyway ;)