Enables you to download files from the server. Hint: Use Sys to zip folders before you download.
Command line interface
Syntax
- $ download filename [filename ...]
Arguments
- filename – (file) One or more files to download.
Example

download.php
- <?
- require("../plugin.php");
- if (is_ajax()) {
- if ($_POST["action"] == 'download') {
- if (!is_file($_POST['file'])) die("1".$_POST['file']); // not file
- if (!is_readable($_POST['file'])) die("2".$_POST['file']); // denied
- die("0".$_POST['file']);
- } else if ($_POST['action'] = 'fetch') {
- header('Content-Type: application/octet-stream');
- header('Content-Disposition: attachment; filename="'.$_POST['file'].'"');
- readfile($_POST['file']);
- }
- exit;
- }
- ?>
- /**
- * Download file
- **/
- TinyShell.plugins.download = new Class({
- description: "Download files from the server",
- run : function(terminal, args) {
- this.t = terminal;
- this.req = args.length;
- this.rec = 0;
- // async download check
- if (args.length) for (var i = 0; i < args.length; i++) this.t.ajax_request(this.print, "<?php echo $_AJAX_URL?>", "action=download&file="+encodeURIComponent(args[i]), true);
- else {
- terminal.print("download: usage: download filename [filename ...]");
- terminal.resume();
- }
- },
- print: function(r) {
- switch (r.substring(0, 1)) {
- case "1":
- this.t.print("download: `"+r.substring(1)+"' is not a file");
- break;
- case "2":
- this.t.print("download: unable to read file `"+r.substring(1)+"'; permission denied");
- break;
- default:
- r = r.substring(1);
- this.t.print("<a href='"+this.t.create_url("<?php echo $_AJAX_URL?>", "action=fetch&file="+encodeURIComponent(r))+"' target='_blank'>Download file: "+r+"</a>", true);
- }
- if (++this.rec >= this.req) this.t.resume();
- }
- });