使用boostrap

时间:2015-05-14 06:25:23

标签: twitter-bootstrap file-upload html-form-post

我是Bootstrap框架的新手。创建了一个小网页来上传文件。提交按钮工作正常,但文件没有上传。



<html>
<head>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">

<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
    <div class="row clearfix">
        <div class="col-md-4 column">
            <h1 class="text-left text-danger">
                Header
            </h1>
        </div>
        <div class="col-md-4 column">
        </div>
        <div class="col-md-4 column">
        </div>
    </div>
    <div class="row clearfix">
        <div class="col-md-2 column">
        </div>
        <div class="col-md-8 column bg-info">
            <div class="row clearfix">
                <div class="col-md-6 column">
                    <form  id="noteForm" name="noteForm" action="upload" method="POST" enctype="multipart/form-data">
                        <div class="form-group">
                             <label for="exampleInputFile1"> File 1</label>
                             <input type="file" id="File1" >
                        </div>
                        <div class="form-group">
                             <label for="exampleInputFile2"> File 2</label>
                             <input type="file" id="File2" >
                        </div>
                        <div class="form-group">
                             <label for="exampleInputFile3"> File 3</label>
                             <input type="file" id="File3" >
                        </div>
                        <div class="form-group">
                             <label for="exampleInputFile4"> File 4</label>
                             <input type="file" id="File4" >
                        </div>
                        <button type="submit" class="btn btn-default">Submit</button>
                    </form>
                </div>
                <div class="col-md-6 column">
                    <h2>
                        Header 2
                    </h2>
                    <p>
                       Some content
                    </p>
                </div>
            </div>
        </div>
        <div class="col-md-2 column">
        </div>
    </div>
</div>


</body>
</html>
&#13;
&#13;
&#13;

没有bootstrap代码的普通html表单工作正常,我可以将文件上传到服务器。我无法弄清楚可能出现的问题。

1 个答案:

答案 0 :(得分:0)

在文件输入元素中用“name”替换“id”属性后,我能够使它工作。

  

<input type="file" id="File1" >

  

<input type="file" name="File1" >