你必须做几件事,
首先是随机服务器
server_pool = ["mydomain.com/files","mydomain2.com/files","mydomain3.com/files","mydomain4.com/files","mydomain5.com/files"];
var theserver = server_pool[Math.floor(Math.random() * server_pool.length)];
现在我们要将随机服务器添加到 blueimp 中的 de main.js 文件中。
替换这个
$('#fileupload').fileupload({
// Uncomment the following to send cross-domain cookies:
//xhrFields: {withCredentials: true},
url: 'server/php/'
});
为了这:
$('#fileupload').fileupload({
// Uncomment the following to send cross-domain cookies:
//xhrFields: {withCredentials: true},
// url: 'server/php/' OLD ONE
url: theserver
});
现在是 PHP 部分的时候了,您需要将 server/php 文件夹上传到所有其他服务器,但首先您需要将其添加到其中的 index.php 文件中。
在后面加上这个
这是结果:
<?php
header('Access-Control-Allow-Origin: *');
/*
* jQuery File Upload Plugin PHP Example 5.14
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2010, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/
error_reporting(E_ALL | E_STRICT);
require('UploadHandler.php');
$upload_handler = new UploadHandler();
干杯