<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<style>
.hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0;}
.input-block-level{display:block;width:100%;min-height:30px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;}
.btn-file{overflow:hidden;position:relative;vertical-align:middle;}.btn-file>input{position:absolute;top:0;right:0;margin:0;opacity:0;filter:alpha(opacity=0);transform:translate(-300px, 0) scale(4);font-size:23px;direction:ltr;cursor:pointer;}
.fileupload{margin-bottom:9px;}.fileupload .uneditable-input{display:inline-block;margin-bottom:0px;vertical-align:middle;cursor:text;}
.fileupload .thumbnail{overflow:hidden;display:inline-block;margin-bottom:5px;vertical-align:middle;text-align:center;}.fileupload .thumbnail>img{display:inline-block;vertical-align:middle;max-height:100%;}
.fileupload .btn{vertical-align:middle;}
.fileupload-exists .fileupload-new,.fileupload-new .fileupload-exists{display:none;}
.fileupload-inline .fileupload-controls{display:inline;}
.fileupload-new .input-append .btn-file{-webkit-border-radius:0 3px 3px 0;-moz-border-radius:0 3px 3px 0;border-radius:0 3px 3px 0;}
.thumbnail-borderless .thumbnail{border:none;padding:0;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;}
.fileupload-new.thumbnail-borderless .thumbnail{border:1px solid #ddd;}
</style>
<div class="fileupload fileupload-new" data-provides="fileupload">
<span class="btn btn-primary btn-file">
<span class="fileupload-new">Выбрать файл</span>
<span class="fileupload-exists">Выбрать другой файл</span>
<input type="file" />
</span>
<span class="fileupload-preview"></span>
<a href="#" class="close fileupload-exists" data-dismiss="fileupload" style="float: none">×</a>
</div>
<script>
var file = undefined;
! function(e) {
var t = function(t, n) {
this.$element = e(t), this.type = this.$element.data("uploadtype") || (this.$element.find(".thumbnail").length > 0 ? "image" : "file"), this.$input = this.$element.find(":file");
if (this.$input.length === 0) return;
this.name = this.$input.attr("name") || n.name, this.$hidden = this.$element.find('input[type=hidden][name="' + this.name + '"]'), this.$hidden.length === 0 && (this.$hidden = e('<input type="hidden" />'), this.$element.prepend(this.$hidden)), this.$preview = this.$element.find(".fileupload-preview");
var r = this.$preview.css("height");
this.$preview.css("display") != "inline" && r != "0px" && r != "none" && this.$preview.css("line-height", r), this.original = {
exists: this.$element.hasClass("fileupload-exists"),
preview: this.$preview.html(),
hiddenVal: this.$hidden.val()
}, this.$remove = this.$element.find('[data-dismiss="fileupload"]'), this.$element.find('[data-trigger="fileupload"]').on("click.fileupload", e.proxy(this.trigger, this)), this.listen()
};
t.prototype = {
listen: function() {
this.$input.on("change.fileupload", e.proxy(this.change, this)), e(this.$input[0].form).on("reset.fileupload", e.proxy(this.reset, this)), this.$remove && this.$remove.on("click.fileupload", e.proxy(this.clear, this))
},
change: function(e, t) {
if (t === "clear") return;
var n = e.target.files !== undefined ? e.target.files[0] : e.target.value ? {
name: e.target.value.replace(/^.+\\/, ""),
size: e.target.value.size,
} : null;
if (!n) {
this.clear();
return
}
this.$hidden.val(""),
this.$hidden.attr("name", ""),
this.$input.attr("name", this.name);
if (typeof FileReader != "undefined") {
var r = new FileReader,
i = this.$preview,
s = this.$element;
r.onload = function(e) {
var result = {
name: n.name,
data: e.target.result,
size: n.size,
}
i.text(result.name), s.addClass("fileupload-exists").removeClass("fileupload-new")
}, r.readAsDataURL(n)
} else this.$preview.text(n.name), this.$element.addClass("fileupload-exists").removeClass("fileupload-new")
},
clear: function(e) {
this.$hidden.val(""), this.$hidden.attr("name", this.name), this.$input.attr("name", "");
if (navigator.userAgent.match(/msie/i)) {
var t = this.$input.clone(!0);
this.$input.after(t), this.$input.remove(), this.$input = t
} else this.$input.val("");
this.$preview.html(""), this.$element.addClass("fileupload-new").removeClass("fileupload-exists"), e && (this.$input.trigger("change", ["clear"]), e.preventDefault())
file = undefined;
},
reset: function(e) {
this.clear(), this.$hidden.val(this.original.hiddenVal), this.$preview.html(this.original.preview), this.original.exists ? this.$element.addClass("fileupload-exists").removeClass("fileupload-new") : this.$element.addClass("fileupload-new").removeClass("fileupload-exists")
},
trigger: function(e) {
this.$input.trigger("click"), e.preventDefault()
}
}, e.fn.fileupload = function(n) {
return this.each(function() {
var r = e(this),
i = r.data("fileupload");
i || r.data("fileupload", i = new t(this, n)), typeof n == "string" && i[n]()
})
}, e.fn.fileupload.Constructor = t, e(document).on("click.fileupload.data-api", '[data-provides="fileupload"]', function(t) {
var n = e(this);
if (n.data("fileupload")) return;
n.fileupload(n.data());
var r = e(t.target).closest('[data-dismiss="fileupload"],[data-trigger="fileupload"]');
r.length > 0 && (r.trigger("click.fileupload"), t.preventDefault())
})
}(window.jQuery)
</script>
/* leave this part out */
body{text-align:center; padding-top:30px;}
/* leave this part out */