New : test of big upload on test_forms
This commit is contained in:
parent
78b0ce6b24
commit
763001625b
@ -35,6 +35,9 @@ if (!defined('NOREQUIREAJAX')) {
|
||||
if (!defined('NOREQUIRESOC')) {
|
||||
define('NOREQUIRESOC', '1');
|
||||
}
|
||||
if (!defined('NOCSRFCHECK')) {
|
||||
define('NOCSRFCHECK', '1');
|
||||
}
|
||||
// If there is no need to load and show top and left menu
|
||||
if (!defined("NOLOGIN")) {
|
||||
define("NOLOGIN", '1');
|
||||
@ -68,7 +71,7 @@ if (!empty($upload_dir)) {
|
||||
$temp_dir = $upload_dir.'/'.$flowIdentifier;
|
||||
} else {
|
||||
$temp_dir = DOL_DATA_ROOT.'/'.$module.'/temp/'.$flowIdentifier;
|
||||
$upload_dir = $temp_dir;
|
||||
$upload_dir = DOL_DATA_ROOT.'/'.$module.'/temp/';
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
@ -133,7 +136,7 @@ function createFileFromChunks($temp_dir, $upload_dir, $fileName, $chunkSize, $to
|
||||
$total_files = 0;
|
||||
$files = dol_dir_list($temp_dir, 'files');
|
||||
foreach ($files as $file) {
|
||||
if (stripos($file, $fileName) !== false) {
|
||||
if (stripos($file["name"], $fileName) !== false) {
|
||||
$total_files++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,6 +105,70 @@ $array = array(1=>'Value 1', 2=>'Value 2', 3=>'Value 3');
|
||||
$arrayselected = array(1, 3);
|
||||
print $form->multiselectarray('testmulti', $array, $arrayselected, '', 0, 'minwidth100');
|
||||
|
||||
print '<br><br>'."\n";
|
||||
|
||||
// Test6a: Upload of big files
|
||||
print "Test 6a: Upload of big files<br>\n";
|
||||
print "The file will be uploaded in the directory: documents/test_form/temp/<br>\n";
|
||||
|
||||
if (is_file(DOL_DOCUMENT_ROOT.'/includes/flowjs/flow.js')) {
|
||||
print '<button id="buttonbigupload" type="button">Browse...</button>';
|
||||
print ' <span id="filespan">No file selected.</span>';
|
||||
print '<br><div class="progress-bar filepgbar taligncenter" role="progressbar" style="width:1%;display:none"><span class="small valigntop">0%</span></div>';
|
||||
print '<br><button type="button" style="display:none;" data-fileidentifier="" class="btn green-haze btn-circle cancelfileinput" id="filecancel">Cancel</button>';
|
||||
print '<script src="'.DOL_URL_ROOT.'/includes/flowjs/flow.js"></script>';
|
||||
print '<script>
|
||||
jQuery(document).ready(function() {
|
||||
var flow = new Flow({
|
||||
target:"'.DOL_URL_ROOT.'/core/ajax/flowjs-server.php",
|
||||
query:{module:"test_form"},
|
||||
testChunks:false
|
||||
});
|
||||
';
|
||||
print 'if(flow.support){
|
||||
flow.assignBrowse(document.getElementById("buttonbigupload"));
|
||||
flow.on("fileAdded", function(file, event){
|
||||
console.log("Trigger event file added", file, event);
|
||||
$("#filespan").text(file.name);
|
||||
$("#filecancel").data("fileidentifier", file.uniqueIdentifier)
|
||||
$("#filecancel").show()
|
||||
$(".filepgbar").show();
|
||||
$(".filepgbar").attr("id",file.uniqueIdentifier+"pgbar")
|
||||
});
|
||||
flow.on("filesSubmitted", function(array,message){
|
||||
console.log("Trigger event file submitted");
|
||||
flow.upload()
|
||||
});
|
||||
flow.on("progress", function(){
|
||||
console.log("progress",flow.files);
|
||||
flow.files.forEach(function(element){
|
||||
console.log(element.progress());
|
||||
width = Math.round(element.progress()*100)
|
||||
width = width.toString()
|
||||
$("#"+element.uniqueIdentifier+"pgbar").width(width+"%")
|
||||
$("#"+element.uniqueIdentifier+"pgbar").children("span").text(width+"%")
|
||||
});
|
||||
});
|
||||
flow.on("fileSuccess", function(file,message){
|
||||
console.log("The file has been uploaded successfully",file,message);
|
||||
});
|
||||
$(".cancelfileinput").on("click", function(){
|
||||
filename = $(this).data("fileidentifier");
|
||||
file = flow.getFromUniqueIdentifier(filename);
|
||||
file.cancel();
|
||||
$("#"+file.uniqueIdentifier+"pgbar").hide();
|
||||
console.log("We remove file "+filename);
|
||||
$("#filespan").text("No file selected.");
|
||||
$(this).hide();
|
||||
})
|
||||
}
|
||||
})
|
||||
';
|
||||
print '</script>';
|
||||
} else {
|
||||
print "If this message displays, please add flow.js file which can be found here :https://github.com/flowjs/flow.js and place the js lib in htdocs/includes/flowjs/<br>\n";
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
|
||||
// End of page
|
||||
|
||||
Loading…
Reference in New Issue
Block a user