#1523 - Error when attaching files to pages without having specified a file

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@43922 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Andrew O'Neil 2007-10-29 01:35:33 +00:00
parent bdf74e499f
commit 20e79f33be

View File

@ -623,10 +623,21 @@ class Image_Uploader extends Controller {
* Save the data in this form.
*/
function save($data, $form) {
if($data['Upload']['size'] == 0) {
// No image has been uploaded
Director::redirectBack();
return;
}
$owner = DataObject::get_by_id($data['Class'], $data['ID']);
$fieldName = $data['Field'] . 'ID';
if($data['ImageSource'] == 'existing') {
if(!$data['ExistingFile']) {
// No image has been selected
Director::redirectBack();
return;
}
$owner->$fieldName = $data['ExistingFile'];
// Edit the class name, if applicable