Javascript 使用blueimp jQuery文件上载
我试图通过PHP将所选文件插入MySQL数据库,从而实现blueimp jQuery文件上传程序 我正在使用您可以找到的Javascript 使用blueimp jQuery文件上载,javascript,php,jquery,mysql,Javascript,Php,Jquery,Mysql,我试图通过PHP将所选文件插入MySQL数据库,从而实现blueimp jQuery文件上传程序 我正在使用您可以找到的Basic Plus UI 表格如下: <form id="fileupload" action="" method="POST" enctype="multipart/form-data"> <!-- Redirect browsers with JavaScript disabled to the origin page -->
Basic Plus UI
表格如下:
<form id="fileupload" action="" method="POST" enctype="multipart/form-data">
<!-- Redirect browsers with JavaScript disabled to the origin page -->
<noscript><input type="hidden" name="redirect" value="http://blueimp.github.io/jQuery-File-Upload/"></noscript>
<!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload -->
<div class="row fileupload-buttonbar">
<div class="col-lg-7">
<!-- The fileinput-button span is used to style the file input field as button -->
<span class="btn btn-success fileinput-button">
<i class="glyphicon glyphicon-plus"></i>
<span>Add files...</span>
<input type="file" name="files[]" multiple>
</span>
<button type="submit" class="btn btn-primary start">
<i class="glyphicon glyphicon-upload"></i>
<span>Start upload</span>
</button>
<button type="reset" class="btn btn-warning cancel">
<i class="glyphicon glyphicon-ban-circle"></i>
<span>Cancel upload</span>
</button>
<button type="button" class="btn btn-danger delete">
<i class="glyphicon glyphicon-trash"></i>
<span>Delete</span>
</button>
<input type="checkbox" class="toggle">
<!-- The global file processing state -->
<span class="fileupload-process"></span>
</div>
<!-- The global progress state -->
<div class="col-lg-5 fileupload-progress fade">
<!-- The global progress bar -->
<div class="progress progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100">
<div class="progress-bar progress-bar-success" style="width:0%;"></div>
</div>
<!-- The extended global progress state -->
<div class="progress-extended"> </div>
</div>
</div>
<!-- The table listing the files available for upload/download -->
<table role="presentation" class="table table-striped"><tbody class="files"></tbody></table>
</form>
添加文件。。。
开始上传
取消上传
删除
我想将表单发送到一个名为process.php
的页面,该页面处理所有数据并将文件上传到DB表
我对jQuery的所有内容都感到困惑,因为表单似乎被发送到了那里
您能帮助我理解如何通过处理所选文件的PHP页面将其发送到db吗
我可以处理所有的处理,我只需要知道如何将表单发送到PHP页面,该页面通过$\u files[files]
获取所有选择的文件
我已尝试设置
action=“process.php”
,但当我单击提交按钮时,这没有任何作用。您必须指定上载处理程序的位置;在fileupload初始化代码上
HTML
<!-- The fileinput-button span is used to style the file input field as button -->
<span class="btn btn-success fileinput-button">
<i class="glyphicon glyphicon-plus"></i>
<span>Add files...</span>
<!-- The file input field used as target for the file upload widget -->
<input id="fileupload" type="file" name="files[]" multiple>
</span>
<br>
<br>
<!-- The global progress bar -->
<div id="progress" class="progress">
<div class="progress-bar progress-bar-success"></div>
</div>
<!-- The container for the uploaded files -->
<div id="files" class="files"></div>
另外,不要编写自己的上传处理程序。看看他们的例子,看看它是如何实现的
看看这些:
- @user3574492:Dude。我正在尝试在asp.net环境中实现相同的解决方案。你猜怎么着?我正在使用处理程序上载我的文件,但它不起作用(不调用我的处理程序),除非我将表单ID重命名为除“fileupload”之外的其他名称,这使上载按钮调用我的处理程序,文件将上载。重命名表单ID后发生的唯一问题是,您无法再看到您选择上载的队列中文件的预览(例如显示上载队列的Gridview)。。。我认为这里应该有一个与表单ID“fileupload”冲突的地方。哦,你能评论一下为什么你投了否决票,而不仅仅是这样做吗?是javascript代码初始化了上传插件;i、 e.
$('#fileupload')。fileupload({…})代码>
$('#fileupload').fileupload({
url: 'server/index.php',
dataType: 'json',
autoUpload: false,
acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
maxFileSize: 5000000, // 5 MB
// Enable image resizing, except for Android and Opera,
// which actually support image resizing, but fail to
// send Blob objects via XHR requests:
disableImageResize: /Android(?!.*Chrome)|Opera/
.test(window.navigator.userAgent),
previewMaxWidth: 100,
previewMaxHeight: 100,
previewCrop: true
// rest of the code snipped