ENHANCEMENT: user-friendly error now present for unwanted upload file types

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@114132 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2010-11-24 06:23:47 +00:00
parent b15019a95f
commit 3ffa3bfe42
2 changed files with 8 additions and 1 deletions

View File

@ -175,7 +175,13 @@ class FileIFrameField extends FileField {
if($data['FileSource'] == 'new') {
$fileObject = Object::create($desiredClass);
$this->upload->loadIntoFile($_FILES['Upload'], $fileObject, $this->folderName);
try {
$this->upload->loadIntoFile($_FILES['Upload'], $fileObject, $this->folderName);
} catch (Exception $e){
$form->sessionMessage(_t('FileIFrameField.DISALLOWEDFILETYPE', 'This filetype is not allowed to be uploaded'), 'bad');
Director::redirectBack();
return;
}
if($this->upload->isError()) {
Director::redirectBack();

View File

@ -240,6 +240,7 @@ $lang['en_US']['File']['Title'] = 'Title';
$lang['en_US']['FileIFrameField']['ATTACH'] = 'Attach %s';
$lang['en_US']['FileIFrameField']['ATTACHONCESAVED'] = '%ss can be attached once you have saved the record for the first time.';
$lang['en_US']['FileIFrameField']['DELETE'] = 'Delete %s';
$lang['en_US']['FileIFrameField']['DISALLOWEDFILETYPE'] = 'This filetype is not allowed to be uploaded';
$lang['en_US']['FileIFrameField']['FILE'] = 'File';
$lang['en_US']['FileIFrameField']['FROMCOMPUTER'] = 'From your Computer';
$lang['en_US']['FileIFrameField']['FROMFILESTORE'] = 'From the File Store';