mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 15:05:42 +00:00
BUGFIX: The EditableFileField crashed when user uploads a not allowed filetype
This commit is contained in:
parent
89c7cf8a15
commit
20e3f3c8cd
@ -660,7 +660,7 @@ JS
|
||||
}
|
||||
|
||||
if(Session::get("FormInfo.{$form->FormName()}.errors")){
|
||||
Director::redirectBack();
|
||||
Controller::curr()->redirectBack();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -701,8 +701,14 @@ JS
|
||||
$upload = new Upload();
|
||||
$file = new File();
|
||||
$file->ShowInSearch = 0;
|
||||
|
||||
$upload->loadIntoFile($_FILES[$field->Name], $file);
|
||||
try {
|
||||
$upload->loadIntoFile($_FILES[$field->Name], $file);
|
||||
} catch( ValidationException $e ) {
|
||||
$validationResult = $e->getResult();
|
||||
$form->addErrorMessage($field->Name, $validationResult->message(), 'bad');
|
||||
Controller::curr()->redirectBack();
|
||||
return;
|
||||
}
|
||||
|
||||
// write file to form field
|
||||
$submittedField->UploadedFileID = $file->ID;
|
||||
@ -734,7 +740,7 @@ JS
|
||||
if($attachments){
|
||||
foreach($attachments as $file){
|
||||
if($file->ID != 0) {
|
||||
$email->attachFile($file->Filename,$file->Filename, HTTP::getMimeType($file->Filename));
|
||||
$email->attachFile($file->Filename, $file->Filename, HTTP::get_mime_type($file->Filename));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user