2010-01-28 08:26:00 +01:00
|
|
|
<?php
|
|
|
|
|
2015-12-17 21:20:49 +01:00
|
|
|
class TestFileUploadPage extends TestPage
|
|
|
|
{
|
2010-01-28 08:26:00 +01:00
|
|
|
}
|
|
|
|
|
2015-12-17 21:20:49 +01:00
|
|
|
class TestFileUploadPage_Controller extends TestPage_Controller
|
|
|
|
{
|
2014-02-17 22:04:11 +01:00
|
|
|
|
2015-12-17 21:20:49 +01:00
|
|
|
private static $allowed_actions = array(
|
|
|
|
'Form'
|
|
|
|
);
|
|
|
|
|
|
|
|
public function Form()
|
|
|
|
{
|
|
|
|
$fields = new FieldList(
|
|
|
|
new EmailField('Email', 'EmailField'),
|
|
|
|
new FileField('AFile', 'FileField'),
|
|
|
|
$aImage = new UploadField('AImage', 'SimpleImageField')
|
|
|
|
);
|
|
|
|
|
|
|
|
$aImage->allowedExtensions = array('jpg', 'gif', 'png');
|
|
|
|
|
|
|
|
$actions = new FieldList(
|
|
|
|
new FormAction('addMember', "Add a member with two Files uploaded")
|
|
|
|
);
|
|
|
|
return new Form($this, "Form", $fields, $actions);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function addMember($data, $form)
|
|
|
|
{
|
|
|
|
$member = new Member();
|
|
|
|
$form->saveInto($member);
|
|
|
|
$member->write();
|
|
|
|
$this->redirectBack();
|
|
|
|
}
|
2014-02-17 22:12:52 +01:00
|
|
|
}
|