You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
4.0 KiB
92 lines
4.0 KiB
{% load staticfiles %}
|
|
<!DOCTYPE HTML>
|
|
<html lang="en">
|
|
<head>
|
|
<!-- Force latest IE rendering engine or ChromeFrame if installed -->
|
|
<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><![endif]-->
|
|
<meta charset="utf-8">
|
|
<title>Django jQuery File Upload Demo - Basic version</title>
|
|
<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.">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<!-- Bootstrap styles -->
|
|
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
|
|
<!-- Generic page styles -->
|
|
<link rel="stylesheet" href="/static/css/style.css">
|
|
<link rel='stylesheet' href='{% static "lib/jquery.fileupload/css/jquery.fileupload.css" %}'>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<h1>Загрузка файлов</h1>
|
|
<ul class="nav nav-tabs">
|
|
<li class="active"><a href="/upload/basic">Basic</a></li>
|
|
<br>
|
|
|
|
<!-- The fileinput-button span is used to style the file input field as button -->
|
|
<span class="btn btn-success fileinput-button">
|
|
<i class="glyphicon glyphicon-plus"></i>
|
|
<span>Выберите файлы</span>
|
|
<!-- The file input field used as target for the file upload widget -->
|
|
<input id="fileupload" type="file" name="file" multiple>
|
|
</span>
|
|
<br>
|
|
<br>
|
|
<!-- The global progress bar -->
|
|
<div id="progress" class="progress">
|
|
<div class="progress-bar progress-bar-success"></div>
|
|
</div>
|
|
<!-- The container for the uploaded files -->
|
|
<div id="files" class="files"></div>
|
|
<br>
|
|
</div>
|
|
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
|
<!-- The jQuery UI widget factory, can be omitted if jQuery UI is already included -->
|
|
<script src="{% static 'lib/jquery.fileupload/js/vendor/jquery.ui.widget.js'%}"></script>
|
|
<!-- The Iframe Transport is required for browsers without support for XHR file uploads -->
|
|
<script src='{% static "lib/jquery.fileupload/js/jquery.iframe-transport.js" %}'></script>
|
|
|
|
<!-- The basic File Upload plugin -->
|
|
<script src='{% static "lib/jquery.fileupload/js/jquery.fileupload.js" %}'></script>
|
|
<!-- Bootstrap JS is not required, but included for the responsive demo navigation -->
|
|
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
|
|
<script>
|
|
/*jslint unparam: true */
|
|
/*global window, $ */
|
|
function csrfSafeMethod(method) {
|
|
// these HTTP methods do not require CSRF protection
|
|
return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
|
|
}
|
|
$(function () {
|
|
'use strict';
|
|
// Change this to the location of your server-side upload handler:
|
|
var url = '/work_sell/basic/';
|
|
var csrftoken = $.cookie('csrftoken');
|
|
$('#fileupload').fileupload({
|
|
url: url,
|
|
crossDomain: false,
|
|
beforeSend: function(xhr, settings) {
|
|
if (!csrfSafeMethod(settings.type)) {
|
|
xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
|
}
|
|
},
|
|
dataType: 'json',
|
|
done: function (e, data) {
|
|
console.log(data);
|
|
$.each(data.result.files, function (index, file) {
|
|
var img = $('<img style="width:200px;height:200px;">').attr('src', file.url).appendTo(document.body);
|
|
});
|
|
},
|
|
progressall: function (e, data) {
|
|
var progress = parseInt(data.loaded / data.total * 100, 10);
|
|
console.log(progress);
|
|
$('#progress .progress-bar').css(
|
|
'width',
|
|
progress + '%'
|
|
);
|
|
}
|
|
}).prop('disabled', !$.support.fileInput)
|
|
.parent().addClass($.support.fileInput ? undefined : 'disabled');
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|
|
|