Upload

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

  1. $ 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

  1. <?
  2. require("../plugin.php");
  3. if (is_ajax()) {
  4. if ($_POST['action'] = 'form'):?>
  5. <?echo "<?xml version='1.0' encoding='utf-8'?>\n"?>
  6. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  7. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="da-DK" lang="da-DK">
  8. <head>
  9. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  10. <meta http-equiv="Content-Type-Script" content="text/javascript" />
  11. <title>TinyShell Upload @ <?=ucwords($_SERVER['SERVER_NAME'])?></title>
  12. <link rel="shortcut icon" type="image/x-icon" href="../favicon.ico" />
  13. <link rel="icon" type="image/x-icon" href="../favicon.ico" />
  14. <link rel="stylesheet" type="text/css" href="../style.css" />
  15. <link rel="stylesheet" type="text/css" href="../theme.css" />
  16. </head>
  17. <body onload="window.setTimeout(function(){window.scrollTo(0,0);},100)">
  18. <form method='post' enctype='multipart/form-data'>
  19. <?
  20. if ($_POST['formaction'] == 'upload' && $_FILES['file'] && $_FILES['file']['name']) {
  21. if (!$_FILES['file']['error'] && is_readable($_FILES['file']['tmp_name']) && @file_put_contents($_FILES['file']['name'], file_get_contents($_FILES['file']['tmp_name'])) !== false) {
  22. ?>
  23. <p>
  24. The file `<?=$_FILES['file']['name']?>' was successfully uploaded at <?=date("H:i")?>
  25. </p>
  26. <?
  27. } else {
  28. ?>
  29. <p>
  30. Failed to upload the file `<?=$_FILES['file']['name']?>' uploaded at <?=date("H:i")?>
  31. </p>
  32. <?
  33. }
  34. }
  35. ?>
  36. <p>
  37. Upload file (max <?=ini_get('post_max_size')?>b) to:
  38. <br />
  39. <strong><?=getcwd()?></strong>
  40. </p>
  41. <p>
  42. <input type='file' name='file' />
  43. <input type='hidden' name='formaction' value='upload' />
  44. <input type='submit' value='Upload' />
  45. </p>
  46. </form>
  47. </body>
  48. </html>
  49. <?endif;
  50. exit;
  51. }
  52. ?>
  53. /**
  54. * Upload file
  55. **/
  56. TinyShell.plugins.upload = new Class({
  57. description: "Upload files to the server",
  58. run : function(terminal, args) {
  59. terminal.print("<a href='"+terminal.create_url("<?php echo $_AJAX_URL?>", "action=form")+"' target='_blank'>Click here to upload files</a>", true);
  60. terminal.resume();
  61. }
  62. });

One Response to Upload

  1. Pingback: lemul0t's blog » Blog Archive » En cour : Introduction au script bash : Communication HTTP

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>