MVC上传文件
方案1:
<form method="post" enctype="multipart/form-data" role="form" class="form-inline">
<h4>
<input type="text" placeholder="请选择上传数据的文件" id="upfiles" class="form-control" />
<input type="file" id="file" />
<button class="btn btn-success " type="button" onclick="file.click()"><i class="fa fa-upload"></i> <span class="bold">上传</span> </button>
</h4>
</form>
方案2:
<head>
<meta name="viewport" content="width=device-width" />
<title>UploadFile</title>
<style type="text/css">
.file-box{ position:relative;width:340px;margin:20px;}
.txt{ height:28px;line-height:28px; border:1px solid #cdcdcd; width:180px;}
.btns{width:65px; color:#fff;background-color:#3598dc; border:0 none;height:28px; line-height:16px!important;cursor:pointer;}
.btn:hover{background-color:#63bfff;color:#fff;}
.file{ position:absolute; top:0; right:85px; height:30px;line-height:30px; filter:alpha(opacity:0);opacity: 0;width:254px }
</style>
</head>
<body>
<div class="file-box">
<form id="uploadForm">
<input type="text" id="textfield" class="txt" />
<input type="button" class="btns" value="浏览..." />
<input type="file" name="file" class="file" id="fileField" onchange="document.getElementById('textfield').value=this.files[0].name" />
<input type="submit" class="btns" value="上传" />
</form>
</div>
</body>
</html>

浙公网安备 33010602011771号