一:將按鈕線下背景圖

代碼:<input type='file' class="img" name='{$field.attr_24}' value=''>
css樣式為:
<style>
.img{
width: 355px;
height: 249px;
background: url(../img/exam.png) no-repeat center;//這個(gè)是背景圖
cursor: pointer;
display: block;
font-size: 0;
line-height: 0;
text-indent: -9999px;
}
</style>
JS為:
<script>
$(".img").change(function(){
var reader = new FileReader();
var file = this.files[0];
reader.readAsDataURL(file);
reader.onloadend = function(){
$(".img").css("background", "url"+"("+ reader.result +")"+" no-repeat");
$(".img-ppoo").css("background-size", "contain");
}
})
</script>