Skip to content
Snippets Groups Projects
Commit 2a940a9e authored by Astor Bizard's avatar Astor Bizard :dog2:
Browse files

Added automatic conversion to Base 64 of binary file upon submission, if there...

Added automatic conversion to Base 64 of binary file upon submission, if there is a corresponding .b64 required file
parent 4c2057fb
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
...@@ -126,7 +126,7 @@ define(['jquery', ...@@ -126,7 +126,7 @@ define(['jquery',
(function() { (function() {
var regExt = /\.([^.]*)$/; var regExt = /\.([^.]*)$/;
var regImg = /^(gif|jpg|jpeg|png|ico)$/i; var regImg = /^(gif|jpg|jpeg|png|ico)$/i;
var regBin = /^(zip|jar|pdf|tar|bin|7z|arj|deb|gzip|rar|rpm|dat|db|rtf|doc|docx|odt)$/i; var regBin = /^(zip|jar|pdf|tar|bin|7z|arj|deb|gzip|rar|rpm|dat|db|rtf|doc|docx|odt|xls|xlsx)$/i;
var regBlk = /^blockly[0123]?$/; var regBlk = /^blockly[0123]?$/;
VPLUtil.fileExtension = function(fileName) { VPLUtil.fileExtension = function(fileName) {
var res = regExt.exec(fileName); var res = regExt.exec(fileName);
......
...@@ -73,8 +73,8 @@ if ($fromform = $mform->get_data()) { ...@@ -73,8 +73,8 @@ if ($fromform = $mform->get_data()) {
$error, 'error' ); $error, 'error' );
die(); die();
} }
$rfn = $vpl->get_fgm('required'); $rfn = $vpl->get_fgm('required');
$minfiles = count( $rfn->getFilelist() ); $reqfiles = $rfn->getFileList();
$files = array (); $files = array ();
for ($i = 0; $i < $instance->maxfiles; $i ++) { for ($i = 0; $i < $instance->maxfiles; $i ++) {
$attribute = 'file' . $i; $attribute = 'file' . $i;
...@@ -87,8 +87,16 @@ if ($fromform = $mform->get_data()) { ...@@ -87,8 +87,16 @@ if ($fromform = $mform->get_data()) {
if ($encode > '') { // If code detected. if ($encode > '') { // If code detected.
$data = iconv( $encode, 'UTF-8', $data ); $data = iconv( $encode, 'UTF-8', $data );
} }
$files [$name] = $data;
}
else {
if (in_array($name . '.b64', $reqfiles)) {
$files [$name . '.b64'] = base64_encode($data);
}
else {
$files [$name] = $data;
}
} }
$files [$name] = $data;
} }
} }
$errormessage = ''; $errormessage = '';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment