Author Topic: Custom file upload...  (Read 5546 times)

Offline laurisnet

  • Newbie
  • *
  • Posts: 9
Custom file upload...
« 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.

Offline rosali

  • Hero Member
  • *****
  • Posts: 2,533
Custom file upload...
« Reply #1 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.
Regards,
Rosali
__________________
MyRoundcube Project (commercial)

Offline laurisnet

  • Newbie
  • *
  • Posts: 9
Custom file upload...
« Reply #2 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

Offline laurisnet

  • Newbie
  • *
  • Posts: 9
Custom file upload...
« Reply #3 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

Offline laurisnet

  • Newbie
  • *
  • Posts: 9
Custom file upload...
« Reply #4 on: April 02, 2009, 08:55:06 AM »
I guess i have to add all necesarry to this $_SESSION['compose']['attachments'][];

Right?

Offline rosali

  • Hero Member
  • *****
  • Posts: 2,533
Custom file upload...
« Reply #5 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.
Regards,
Rosali
__________________
MyRoundcube Project (commercial)

Offline laurisnet

  • Newbie
  • *
  • Posts: 9
Custom file upload...
« Reply #6 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?

Offline rosali

  • Hero Member
  • *****
  • Posts: 2,533
Custom file upload...
« Reply #7 on: April 02, 2009, 11:18:35 AM »
The upload creates a $_FILES array. Uploads do not touch the $_SESSION array() automatically.
Regards,
Rosali
__________________
MyRoundcube Project (commercial)

Offline laurisnet

  • Newbie
  • *
  • Posts: 9
Custom file upload...
« Reply #8 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

Offline rosali

  • Hero Member
  • *****
  • Posts: 2,533
Custom file upload...
« Reply #9 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.
Regards,
Rosali
__________________
MyRoundcube Project (commercial)

Offline laurisnet

  • Newbie
  • *
  • Posts: 9
Custom file upload...
« Reply #10 on: April 02, 2009, 02:10:20 PM »
ok thanks anyway ;)