|
| 1 | +<!DOCTYPE HTML> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | +<!-- Force latest IE rendering engine or ChromeFrame if installed --> |
| 5 | +<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><![endif]--> |
| 6 | +<meta charset="utf-8"> |
| 7 | +<title>Django jQuery File Upload Demo - Basic version</title> |
| 8 | +<meta name="description" content="File Upload widget with multiple file selection, drag&drop support and progress bar for jQuery. Supports cross-domain, chunked and resumable file uploads. Works with any server-side platform (PHP, Python, Ruby on Rails, Java, Node.js, Go etc.) that supports standard HTML form file uploads."> |
| 9 | +<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 10 | +<!-- Bootstrap styles --> |
| 11 | +<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css"> |
| 12 | +<!-- Generic page styles --> |
| 13 | +<link rel="stylesheet" href="{{ STATIC_URL }}css/style.css"> |
| 14 | +<!-- CSS to style the file input field as button and adjust the Bootstrap progress bars --> |
| 15 | +<link rel="stylesheet" href="{{ STATIC_URL }}css/jquery.fileupload-ui.css"> |
| 16 | +</head> |
| 17 | +<body> |
| 18 | +<div class="navbar navbar-default navbar-fixed-top"> |
| 19 | + <div class="container"> |
| 20 | + <div class="navbar-header"> |
| 21 | + <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-fixed-top .navbar-collapse"> |
| 22 | + <span class="icon-bar"></span> |
| 23 | + <span class="icon-bar"></span> |
| 24 | + <span class="icon-bar"></span> |
| 25 | + </button> |
| 26 | + <a class="navbar-brand" href="https://github.com/sigurdga/django-jquery-file-upload">Django jQuery File Upload</a> |
| 27 | + </div> |
| 28 | + <div class="navbar-collapse collapse"> |
| 29 | + <ul class="nav navbar-nav"> |
| 30 | + <li class="active"><a href="#">Demo</a></li> |
| 31 | + <li><a href="https://github.com/sigurdga/django-jquery-file-upload">Source Code</a></li> |
| 32 | + <li><a href="https://github.com/blueimp/jQuery-File-Upload/wiki">Documentation</a></li> |
| 33 | + </ul> |
| 34 | + </div> |
| 35 | + </div> |
| 36 | +</div> |
| 37 | +<div class="container"> |
| 38 | + <h1>jQuery File Upload Demo</h1> |
| 39 | + <h2 class="lead">Basic version</h2> |
| 40 | + <ul class="nav nav-tabs"> |
| 41 | + <li class="active"><a href="/upload/basic">Basic</a></li> |
| 42 | + <li><a href="basic-plus.html" style="display:none;">Basic Plus</a></li> |
| 43 | + <li><a href="/upload/new">Basic Plus UI</a></li> |
| 44 | + <li><a href="angularjs.html" style="display:none;">AngularJS</a></li> |
| 45 | + <li><a href="jquery-ui.html" style="display:none;">jQuery UI</a></li> |
| 46 | + </ul> |
| 47 | + <br> |
| 48 | + <blockquote> |
| 49 | + <p>File Upload widget with multiple file selection, drag&drop support and progress bar for jQuery.<br> |
| 50 | + Supports cross-domain, chunked and resumable file uploads.<br> |
| 51 | + Works with any server-side platform (PHP, Python, Ruby on Rails, Java, Node.js, Go etc.) that supports standard HTML form file uploads.</p> |
| 52 | + </blockquote> |
| 53 | + <br> |
| 54 | + {% csrf_token %} |
| 55 | + <!-- The fileinput-button span is used to style the file input field as button --> |
| 56 | + <span class="btn btn-success fileinput-button"> |
| 57 | + <i class="glyphicon glyphicon-plus"></i> |
| 58 | + <span>Select files...</span> |
| 59 | + <!-- The file input field used as target for the file upload widget --> |
| 60 | + <input id="fileupload" type="file" name="file" multiple> |
| 61 | + </span> |
| 62 | + <br> |
| 63 | + <br> |
| 64 | + <!-- The global progress bar --> |
| 65 | + <div id="progress" class="progress"> |
| 66 | + <div class="progress-bar progress-bar-success"></div> |
| 67 | + </div> |
| 68 | + <!-- The container for the uploaded files --> |
| 69 | + <div id="files" class="files"></div> |
| 70 | + <br> |
| 71 | + <div class="panel panel-default"> |
| 72 | + <div class="panel-heading"> |
| 73 | + <h3 class="panel-title">Demo Notes</h3> |
| 74 | + </div> |
| 75 | + <div class="panel-body"> |
| 76 | + <ul> |
| 77 | + <li>You can <strong>drag & drop</strong> files from your desktop on this webpage (see <a href="https://github.com/blueimp/jQuery-File-Upload/wiki/Browser-support">Browser support</a>).</li> |
| 78 | + <li>Please refer to the <a href="https://github.com/blueimp/jQuery-File-Upload">project website</a> and <a href="https://github.com/blueimp/jQuery-File-Upload/wiki">documentation</a> for more information.</li> |
| 79 | + <li>Built with Twitter's <a href="http://twitter.github.com/bootstrap/">Bootstrap</a> CSS framework and Icons from <a href="http://glyphicons.com/">Glyphicons</a>.</li> |
| 80 | + </ul> |
| 81 | + </div> |
| 82 | + </div> |
| 83 | +</div> |
| 84 | +<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> |
| 85 | +<!-- The jQuery UI widget factory, can be omitted if jQuery UI is already included --> |
| 86 | +<script src="{{ STATIC_URL }}js/vendor/jquery.ui.widget.js"></script> |
| 87 | +<!-- The Iframe Transport is required for browsers without support for XHR file uploads --> |
| 88 | +<script src="{{ STATIC_URL }}js/jquery.iframe-transport.js"></script> |
| 89 | +<!-- The basic File Upload plugin --> |
| 90 | +<script src="{{ STATIC_URL }}js/jquery.fileupload.js"></script> |
| 91 | +<!-- Bootstrap JS is not required, but included for the responsive demo navigation --> |
| 92 | +<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> |
| 93 | +<script src="{{ STATIC_URL }}js/csrf.js"></script> |
| 94 | +<script src="{{ STATIC_URL }}js/jquery.cookie.js"></script> |
| 95 | +<script> |
| 96 | +/*jslint unparam: true */ |
| 97 | +/*global window, $ */ |
| 98 | +function csrfSafeMethod(method) { |
| 99 | + // these HTTP methods do not require CSRF protection |
| 100 | + return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method)); |
| 101 | +} |
| 102 | +$(function () { |
| 103 | + 'use strict'; |
| 104 | + // Change this to the location of your server-side upload handler: |
| 105 | + var url = '/upload/basic/'; |
| 106 | + var csrftoken = $.cookie('csrftoken'); |
| 107 | + $('#fileupload').fileupload({ |
| 108 | + url: url, |
| 109 | + crossDomain: false, |
| 110 | + beforeSend: function(xhr, settings) { |
| 111 | + if (!csrfSafeMethod(settings.type)) { |
| 112 | + xhr.setRequestHeader("X-CSRFToken", csrftoken); |
| 113 | + } |
| 114 | + }, |
| 115 | + dataType: 'json', |
| 116 | + done: function (e, data) { |
| 117 | + $.each(data.result.files, function (index, file) { |
| 118 | + $('<p/>').text(file.name).appendTo('#files'); |
| 119 | + }); |
| 120 | + }, |
| 121 | + progressall: function (e, data) { |
| 122 | + var progress = parseInt(data.loaded / data.total * 100, 10); |
| 123 | + $('#progress .progress-bar').css( |
| 124 | + 'width', |
| 125 | + progress + '%' |
| 126 | + ); |
| 127 | + } |
| 128 | + }).prop('disabled', !$.support.fileInput) |
| 129 | + .parent().addClass($.support.fileInput ? undefined : 'disabled'); |
| 130 | +}); |
| 131 | +</script> |
| 132 | +</body> |
| 133 | +</html> |
0 commit comments