Commit 72f60248 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Fix 976451f8 for safari/chrome uploads within a view (see bug #634147 and...

Fix 976451f8 for safari/chrome uploads within a view (see bug #634147 and Nigel's comment on a86bb04f

)
Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent 52d0cb03
......@@ -495,38 +495,39 @@ function pieform_element_filebrowser_doupdate(Pieform $form, $element) {
'browse' => 1,
);
}
else {
if (strlen($_FILES['userfile']['name']) > 1024) {
return array(
'error' => true,
'message' => get_string('nametoolong', 'artefact.file'),
);
}
else if ($element['config']['uploadagreement'] && !param_boolean($prefix . '_notice', false)) {
return array(
'error' => true,
'message' => get_string('youmustagreetothecopyrightnotice', 'artefact.file'),
'browse' => 1,
);
}
if (!empty($_FILES['userfile']['name'])) {
if (strlen($_FILES['userfile']['name']) > 1024) {
return array(
'error' => true,
'message' => get_string('nametoolong', 'artefact.file'),
);
}
else if ($element['config']['uploadagreement'] && !param_boolean($prefix . '_notice', false)) {
return array(
'error' => true,
'message' => get_string('youmustagreetothecopyrightnotice', 'artefact.file'),
'browse' => 1,
);
}
$result = pieform_element_filebrowser_upload($form, $element, array(
'userfile' => $_FILES['userfile'],
'uploadnumber' => param_integer($prefix . '_uploadnumber'),
'uploadfolder' => $element['folder'] ? $element['folder'] : null,
'uploadfoldername' => param_variable($prefix . '_foldername'),
));
// If it's a non-js upload, automatically select the newly uploaded file.
$result['browse'] = 1;
if (!$form->submitted_by_js() && !$result['error'] && !empty($element['config']['select'])) {
if (isset($element['selectcallback']) && is_callable($element['selectcallback'])) {
$element['selectcallback']($result['highlight']);
}
$result = pieform_element_filebrowser_upload($form, $element, array(
'userfile' => $_FILES['userfile'],
'uploadnumber' => param_integer($prefix . '_uploadnumber'),
'uploadfolder' => $element['folder'] ? $element['folder'] : null,
'uploadfoldername' => param_variable($prefix . '_foldername'),
));
// If it's a non-js upload, automatically select the newly uploaded file.
$result['browse'] = 1;
if (!$form->submitted_by_js() && !$result['error'] && !empty($element['config']['select'])) {
if (isset($element['selectcallback']) && is_callable($element['selectcallback'])) {
$element['selectcallback']($result['highlight']);
}
else {
$result['select'] = $result['highlight'];
}
else {
$result['select'] = $result['highlight'];
}
return $result;
}
return $result;
}
if (!$form->submitted_by_js()) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment