/* ------------------------------------------------------------------------------ * * # Bootstrap multiple file uploader * * Specific JS code additions for uploader_bootstrap.html page * * Version: 1.1 * Latest update: Dec 11, 2015 * * ---------------------------------------------------------------------------- */ $(function() { // Basic example $('.file-input').fileinput({ browseLabel: 'Browse', browseIcon: '', uploadIcon: '', removeIcon: '', layoutTemplates: { icon: '' }, initialCaption: "No file selected" }); // Custom layout $('.file-input-custom').fileinput({ previewFileType: 'image', browseLabel: 'Select', browseClass: 'btn bg-slate-700', browseIcon: ' ', removeLabel: 'Remove', removeClass: 'btn btn-danger', removeIcon: ' ', uploadClass: 'btn bg-teal-400', uploadIcon: ' ', layoutTemplates: { icon: '' }, initialCaption: "Please select image", mainClass: 'input-group' }); // Template modifications $('.file-input-advanced').fileinput({ browseLabel: 'Browse', browseClass: 'btn btn-default', removeClass: 'btn btn-default', uploadClass: 'btn bg-success-400', browseIcon: '', uploadIcon: '', removeIcon: '', layoutTemplates: { icon: '', main1: "{preview}\n" + "
",
"
",
],
overwriteInitial: false,
maxFileSize: 100
});
// Display preview on load
$(".file-input-overwrite").fileinput({
browseLabel: 'Browse',
browseIcon: '',
uploadIcon: '',
removeIcon: '',
initialPreview: [
"
",
"
",
],
overwriteInitial: true
});
// Disable/enable button
$("#btn-modify").on("click", function() {
$btn = $(this);
if ($btn.text() == "Disable file input") {
$("#file-input-methods").fileinput("disable");
$btn.html("Enable file input");
alert("Hurray! I have disabled the input and hidden the upload button.");
}
else {
$("#file-input-methods").fileinput("enable");
$btn.html("Disable file input");
alert("Hurray! I have reverted back the input to enabled with the upload button.");
}
});
// AJAX upload
$(".file-input-ajax").fileinput({
uploadUrl: "http://localhost", // server upload action
uploadAsync: true,
maxFileCount: 5,
initialPreview: [],
fileActionSettings: {
removeIcon: '',
removeClass: 'btn btn-link btn-xs btn-icon',
uploadIcon: '',
uploadClass: 'btn btn-link btn-xs btn-icon',
indicatorNew: '',
indicatorSuccess: '',
indicatorError: '',
indicatorLoading: '',
}
});
});