文件上传按钮不起作用

时间:2015-11-26 15:04:59

标签: php html5 twitter-bootstrap

我想在bootstrap中上传文件,它只在chrome上工作而不在firefox中,我想为两个浏览器工作,如果有人可以修复问题也行,否则给我链接bootstrap fileupload,我搜索了我不能得到,我尝试了这个,但我不知道如何插入这个值有点困难任何一个知道的方法告诉我http://blueimp.github.io/jQuery-File-Upload/

<button class="btn btn-primary" data-toggle="modal" data-target="#formModal">
    Launch Form Modal
</button>
<div class="modal fade" id="formModal" tabindex="-1" role="dialog" aria-labelledby="formModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="formModalLabel">Large Modal Title</h4>
            </div>
            <div class="modal-body">
                <form form action="original_photo_upload.php" method="post" enctype="multipart/form-data" class="form-horizontal" style="margin-top: 20px;">

                                                <div class="form-group">
                                                    <label class="control-label col-xs-3">File Upload</label>
                                                    <div class="col-md-9">
                                                        <div class="fileupload fileupload-new" data-provides="fileupload">
                                                            <div class="input-append">
                                                                <div class="uneditable-input">
                                                                    <i class="fa fa-file fileupload-exists"></i>
                                                                    <span class="fileupload-preview"></span>
                                                                </div>
                                                                <span class="btn btn-default btn-file">
                                                                    <span class="fileupload-exists">Change</span>
                                                                    <span class="fileupload-new">Select file</span>
                                                                    <input type="file" name="file" required>

                                                                </span>
                                                                <a href="#" class="btn btn-default fileupload-exists" data-dismiss="fileupload">Remove</a>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>

                                                <div class="form-group">
                                                    <div class="col-xs-offset-4 col-xs-8">
                                                        <button type="submit" value="register" class="btn btn-primary" id='btn-submit'>Upload The Photo</button>
                                                    </div>
                                                </div>

                                            </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                <button type="button" class="btn btn-primary">Save Changes</button>
            </div>
        </div>
    </div>
</div>

1 个答案:

答案 0 :(得分:2)

为表单添加enctype="multipart/form-data"以使用上传功能。

<form id="demo-form" class="form-horizontal mb-lg" novalidate="novalidate" enctype="multipart/form-data">