summaryrefslogtreecommitdiff
path: root/static/upload-test.html
blob: 1590b6687daf38f74557d4a14eb286d962c8b2d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<html>
  <head>
    <title>DUMP file upload test</title>
    <script type="text/javascript" 
            src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
    <script type="text/javascript"
            src="/static/js/jquery.form.js"></script>

    <script>
      args = 1;
      $(document).ready(function() {
          var error = function(resp) {
               $('#result').hide().css({'color': 'red'})
                   .html(resp.statusText).fadeIn(250); 
          }
          var success = function(imageUrl) {
              imageUrl = $.trim(imageUrl);
              console.log(imageUrl, imageUrl.length);
              if ($.trim(imageUrl) == "NOT_LOGGED_IN") {
                  error({statusText: "Not logged in!" });
                  return;
              }
              $('#result').hide().css({'color': 'green'}) 
                   .html('<img src="' + imageUrl + '">').fadeIn(250);              
          }

          $('#test').ajaxForm({
              url: '/upload',
              type: 'POST',
              dataType: 'text',
              success: success,
              error: error
          });
      });
    </script>
  </head>
  <body>
    <h2>Upload File</h2>
    <form id="test" enctype="multipart/form-data">
      <input type="hidden" name="room" value="RoomA">
      <input type="file" name="image">
      <br />
      <input type="submit">
    </form>
    <div id="result"></div>
  </body>
</html>