Author Topic: download file through plugin  (Read 4969 times)

Offline alpha_beta

  • Newbie
  • *
  • Posts: 7
download file through plugin
« on: March 24, 2013, 12:18:44 PM »
Hi,

Download a file using "php readfile" in an action. For example a link "a href=?_task=something&_action=download&file=1"

Upon clicking this link the action should return the file without any html page output.

Any help on how to achieve this will be highly appreciated. I just cant get an understanding of how mail attachment are downloaded.
« Last Edit: March 24, 2013, 03:48:48 PM by alpha_beta »

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,879
    • SKaero - Custom Roundcube development
Re: download file through plugin
« Reply #1 on: March 24, 2013, 01:53:38 PM »
You should be able to do it very simply, have you read the plugin documentation? http://trac.roundcube.net/wiki/Doc_Plugins

Offline alpha_beta

  • Newbie
  • *
  • Posts: 7
Re: download file through plugin
« Reply #2 on: March 24, 2013, 04:03:56 PM »
I read the docs and have implemented couple of plugins. I need to understand a way to achieve this within roundcube's framework probably through pointers with examples.

Offline alec

  • Hero Member
  • *****
  • Posts: 1,365
Re: download file through plugin
« Reply #3 on: March 25, 2013, 02:32:25 AM »
?_task=mail&_action=get&_mbox=INBOX&_uid=123&_part=1&_download=1

Offline alpha_beta

  • Newbie
  • *
  • Posts: 7
Re: download file through plugin
« Reply #4 on: March 26, 2013, 01:32:25 PM »
?_task=mail&_action=get&_mbox=INBOX&_uid=123&_part=1&_download=1

Following the "message part" above I see RC loading another file to handle the download. My aim is to use RC's security feature to control access to the application being implemented. The application is a secondary download link to private files listed in a task not mail attachments.

I tried template hooks http://trac.roundcube.net/wiki/Plugin_Hooks#send_page and emptied the content but I got 2 bytes added to php readfile output.  I decided to go with the code below since the main aim is RC's security and working within its frame.
Code: [Select]
//file: doreadfile.php
<?php

require_once 'program/include/iniset.php';
$RCMAIL rcmail::get_instance();
if( 
$RCMAIL->session->check_auth()){
//do readfile stuffs here
}

?>

Now the link will point to doreadfile.php. If you have a better way of achieving this within the plugin API or RC's frame please do let me know.