Добрый день. Использую для загрузки файлов на сервер скрипт dropzone.js но он из коробки поддерживает только загрузку локальных файлов. Как мне заставить его загружать файлы с удаленного сервера? Код загрузки локального файла
var FormDropzone = function () {
return {
//main function to initiate the module
init: function () {
Dropzone.options.myDropzone = {
thumbnailWidth: $width,
thumbnailHeight: $height,
headers: {
"Accept": "",
"Cache-Control": "",
"X-Requested-With": "XMLHttpRequest"
},
dictDefaultMessage: "",
init: function() {
if ($("#$inputId").val() != '') {
var id = $("#$inputId").val();
id = id.replace('$domain', '');
var dropzone = this;
$.ajax({
url: '$domain/file/info/',
dataType: 'json',
data: {
id: id
},
}).success(function (mockFile) {
dropzone.emit("addedfile", mockFile);
dropzone.emit("thumbnail", mockFile, '$urlResize');
$("#$inputId").val();
$('.dz-progress').hide();
$('#my-dropzone > p').hide();
});
}
this.on("addedfile", function(file) {
// Create the remove button
var removeButton = Dropzone.createElement("<a href='javascript:;'' class='btn red btn-sm btn-block'>Удалить</a>");
// Capture the Dropzone instance as closure.
var _this = this;
// Listen to the click event
removeButton.addEventListener("click", function(e) {
// Make sure the button click doesn't submit the form:
e.preventDefault();
e.stopPropagation();
// Remove the file preview.
_this.removeFile(file);
// If you want to the delete the file on the server as well,
// you can do the AJAX request here.
});
// Add the button to the file preview element.
file.previewElement.appendChild(removeButton);
});
this.on("success", function(file, responseText) {
var result = jQuery.parseJSON(responseText);
console.log(result.File);
if (result.File != null) {
$('#$inputId').val(result.domain + result.File);
}
// Handle the responseText here. For example, add the text to the preview element:
//file.previewTemplate.appendChild(document.createTextNode(responseText));
});
}
}
}
};
}();
jQuery(document).ready(function() {
FormDropzone.init();
});
Кофе для программистов: как напиток влияет на продуктивность кодеров?
Рекламные вывески: как привлечь внимание и увеличить продажи
Стратегії та тренди в SMM - Технології, що формують майбутнє сьогодні
Выделенный сервер, что это, для чего нужен и какие характеристики важны?
Современные решения для бизнеса: как облачные и виртуальные технологии меняют рынок
Есть таблица, содержащая следующие поля: ID, FirstUserID, SecondUserID, FirstUserCount, SecondUserCountПри этом гарантируется, что FirstUserID <= SecondUserID
Есть задачаНужно вбить в поле процент, и на этот процент уменьшить увеличить поле price в выбранной категории, а значение которое было в поле...