Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 15th, 2012  |  syntax: None  |  size: 1.32 KB  |  hits: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. res.end(
  2.                         '<html>'+
  3.                                 '<head>'+
  4.                                         '<script type="text/javascript" src="/nowjs/now.js"></script>'+
  5.                                         '<script type="text/javascript">'+
  6.                                                 'now.ready(function() {'+
  7.                                                 '       alert("Hi, this is a now.js test.");'+
  8.                                                 '       var files = {};'+
  9.                                                        
  10.                                                 '       now.startFileReceival = function(id, fileName, bytesExpected, cb) {'+
  11.                                                 '               //this file id must be unique'+
  12.                                                 '               if (typeof(files[id]) !== "undefined") {'+
  13.                                                 '                       cb(false);'+
  14.                                                 '                       return;'+
  15.                                                 '               }'+
  16.                                                                
  17.                                                 '               //add this file'+
  18.                                                 '               files[id] = {fileName: fileName, bytesExpected: bytesExpected, data: ""};'+
  19.                                                                
  20.                                                 '               //success'+
  21.                                                 '               cb(true);'+
  22.                                                 '       };'+
  23.                                                        
  24.                                                 '       now.receiveFileChunk = function(id, chunk, cb) {'+
  25.                                                 '               //this id must exist'+
  26.                                                 '               if (typeof(files[id]) === "undefined") {'+
  27.                                                 '                       cb(false);'+
  28.                                                 '                       return;'+
  29.                                                 '               }'+
  30.                                                                
  31.                                                 '               //add this chunk'+
  32.                                                 '               files[id].data += chunk;'+
  33.                                                                
  34.                                                 '               //success'+
  35.                                                 '               cb(true);'+
  36.                                                 '       };'+
  37.                                                 '});'+
  38.                                         '</script>'+
  39.                                 '</head>'+
  40.                                 '<body>'+
  41.                                         '<form action="/upload" enctype="multipart/form-data" method="post">'+
  42.                                                 '<input type="text" name="title"><br>'+
  43.                                                 '<input type="file" name="upload" multiple="multiple"><br>'+
  44.                                                 '<input type="submit" value="Upload">'+
  45.                                         '</form>'+
  46.                                 '</body>'+
  47.                         '</html>'
  48.         );