Просмотр
Browse
Изображение типа ввода=файл
Внешний JavaScript
var filesToUpload = [];
$.fn.fileUploader = function (filesToUpload) {
this.closest(".files").change(function (evt) {
for (var i = 0; i < evt.target.files.length; i++) {
filesToUpload.push(evt.target.files);
};
var output = [];
for (var i = 0, f; f = evt.target.files; i++) {
var removeLink = "";
output.push("[*]", escape(f.name), " - ", removeLink, " ");
}
$(this).children(".fileList").append(output.join(""));
});
};
$(document).on("click",".removeFile", function(e){
e.preventDefault();
var fileName = $(this).parent().children("strong").text();
// loop through the files array and check if the name of that file matches FileName
// and get the index of the match
for(i = 0; i < filesToUpload.length; ++ i){
if(filesToUpload.name == fileName){
// remove the one element at the index where we get a match
filesToUpload.splice(i, 1);
}
}
// remove the element of the removed file from the page DOM
$(this).parent().remove();
});
$("#files1").fileUploader(filesToUpload);
Подробнее здесь: https://stackoverflow.com/questions/670 ... tting-form
Мобильная версия