![](/img/trans.png)
[英]Blueimp jQuery File Uploader and save filesize into database
[英]How to use Blueimp jQuery file uploader with PHP?
我正在嘗試實現Blueimp jQuery文件上傳器,並且讓我在基於PHP的網站中無法正常工作。
我的主要問題是AJAX。 我想做的就是上傳之后
abc.php
。 我知道如何使用PHP處理數據庫,但不知道我不能將PHP代碼放在哪里。
對於第一個問題,我想我需要更改main.js
$(function () {
'use strict';
// Initialize the jQuery File Upload widget:
$('#fileupload').fileupload();
// Enable iframe cross-domain access via redirect option:
$('#fileupload').fileupload(
'option',
'redirect',
window.location.href.replace(
/\/[^\/]*$/,
'/cors/result.html?%s'
)
);
// Load existing files:
$('#fileupload').each(function () {
var that = this;
$.getJSON(this.action, function (result) {
if (result && result.length) {
$(that).fileupload('option', 'done')
.call(that, null, {result: result});
}
});
});
});
謝謝百萬
要進行重定向,最好是通過PHP提交表單並處理所有操作,除非您丟失進度指示器,否則我猜是這樣。
否則,如果我對您的理解正確,則只需使用回調函數在上傳完成后執行javascript重定向即可。 您只需向以下方法之一添加選項:
$('#fileupload').fileupload({
done: function (e, data) {
// Do redirect using either href or replace method
// similar behavior as clicking on a link
window.location.href = "/abc.php";
}
});
請參閱有關重定向的以下答案: 如何在JavaScript / jQuery中重定向到另一個網頁?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.