【问题标题】:Not able to upload file when using boostrap使用引导程序时无法上传文件
【发布时间】:2015-07-25 16:14:41
【问题描述】:

我是 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>

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

【问题讨论】:

  • 向我们展示您的文件上传代码..

标签: twitter-bootstrap file-upload forms http-post


【解决方案1】:

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

&lt;input type="file" id="File1" &gt;

&lt;input type="file" name="File1" &gt;

【讨论】:

    猜你喜欢
    • 2021-08-10
    • 1970-01-01
    • 2011-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-10
    • 1970-01-01
    相关资源
    最近更新 更多