bootstrap 好看的上传组件
html
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="https://cdn.bootcss.com/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body>
<form class="form-inline" action="">
<div class="container">
<div class="row">
<div class="form-group">
<div class="col-sm-4 control-label">选择文件</div>
<div class="col-sm-8">
<div class="input-group">
<input id=\'location\' class="form-control" onclick="$(\'#i-file\').click();">
<label class="input-group-btn">
<input type="button" id="i-check" value="浏览文件" class="btn btn-primary"
onclick="$(\'#i-file\').click();">
</label>
</div>
</div>
<input type="file" name="file" id=\'i-file\' accept=".xls, .xlsx"
onchange="$(\'#location\').val($(\'#i-file\').val());" style="display: none">
</div>
</div>
</div>
</form>
</body>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript" src="https://cdn.bootcss.com/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
</html>
效果图
更新样式
<form class="form-inline">
<div class="form-group">
<label for="exampleInputName2">图片</label>
<div class="input-group">
<input id=\'exampleInputName2\' class="form-control" onclick="$(\'#i-file\').click();">
<label class="input-group-btn">
<input type="button" id="i-check" value="浏览文件" class="btn btn-primary"
onclick="$(\'#i-file\').click();">
</label>
</div>
<input type="file" name="file" id=\'i-file\' accept=".xls, .xlsx"
onchange="$(\'#location\').val($(\'#i-file\').val());" style="display: none">
</div>
<button type="submit" class="btn btn-default">提交</button>
</form>
效果如下: