Upload files to current working directory on the server. Hint: Upload zipped files and use Sys to unzip. The application opens a new window with an upload form.
Command line interface
Syntax
- $ upload
Arguments
This command takes no arguments.
Example

Todo
- Make option to use chunked upload via Flash or Java plugin, to eliminate maximum upload size.
upload.php
- <?
- require("../plugin.php");
- if (is_ajax()) {
- if ($_POST['action'] = 'form'):?>
- <?echo "<?xml version='1.0' encoding='utf-8'?>\n"?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="da-DK" lang="da-DK">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <meta http-equiv="Content-Type-Script" content="text/javascript" />
- <title>TinyShell Upload @ <?=ucwords($_SERVER['SERVER_NAME'])?></title>
- <link rel="shortcut icon" type="image/x-icon" href="../favicon.ico" />
- <link rel="icon" type="image/x-icon" href="../favicon.ico" />
- <link rel="stylesheet" type="text/css" href="../style.css" />
- <link rel="stylesheet" type="text/css" href="../theme.css" />
- </head>
- <body onload="window.setTimeout(function(){window.scrollTo(0,0);},100)">
- <form method='post' enctype='multipart/form-data'>
- <?
- if ($_POST['formaction'] == 'upload' && $_FILES['file'] && $_FILES['file']['name']) {
- if (!$_FILES['file']['error'] && is_readable($_FILES['file']['tmp_name']) && @file_put_contents($_FILES['file']['name'], file_get_contents($_FILES['file']['tmp_name'])) !== false) {
- ?>
- <p>
- The file `<?=$_FILES['file']['name']?>' was successfully uploaded at <?=date("H:i")?>
- </p>
- <?
- } else {
- ?>
- <p>
- Failed to upload the file `<?=$_FILES['file']['name']?>' uploaded at <?=date("H:i")?>
- </p>
- <?
- }
- }
- ?>
- <p>
- Upload file (max <?=ini_get('post_max_size')?>b) to:
- <br />
- <strong><?=getcwd()?></strong>
- </p>
- <p>
- <input type='file' name='file' />
- <input type='hidden' name='formaction' value='upload' />
- <input type='submit' value='Upload' />
- </p>
- </form>
- </body>
- </html>
- <?endif;
- exit;
- }
- ?>
- /**
- * Upload file
- **/
- TinyShell.plugins.upload = new Class({
- description: "Upload files to the server",
- run : function(terminal, args) {
- terminal.print("<a href='"+terminal.create_url("<?php echo $_AJAX_URL?>", "action=form")+"' target='_blank'>Click here to upload files</a>", true);
- terminal.resume();
- }
- });
Pingback: lemul0t's blog » Blog Archive » En cour : Introduction au script bash : Communication HTTP