public function index(SS_HTTPRequest $r) {
		if(isset($_FILES["Filedata"]) && is_uploaded_file($_FILES["Filedata"]["tmp_name"])) {
			$upload_folder = urldecode($r->requestVar('uploadFolder'));
			if(isset($_REQUEST['FolderID'])) {
				if($folder = DataObject::get_by_id("Folder", Convert::raw2sql($_REQUEST['FolderID']))) {
					$upload_folder = UploadifyField::relative_asset_dir($folder->Filename);
				}
			}
			$ext = strtolower(end(explode('.', $_FILES['Filedata']['name'])));
			$class = in_array($ext, UploadifyField::$image_extensions) ? $r->requestVar('imageClass') : $r->requestVar('fileClass');
			$file = new $class();
			$u = new Upload();
			$u->loadIntoFile($_FILES['Filedata'], $file, $upload_folder);
			$file->write();
			echo $file->ID;
		} 
		else {
			echo ' '; // return something or SWFUpload won't fire uploadSuccess
		}	
	}
	/**
	 * Load the requirements and return a formfield to the template. Ensure "multi" is on.
	 *
	 * @return UploadifyField
	 */
	public function FieldHolder() {
		$f = parent::FieldHolder();
		if($this->Sortable()) {
			Requirements::javascript('dataobject_manager/javascript/dom_jquery_ui.js');
			Requirements::css('dataobject_manager/css/dom_jquery_ui.css');
		}
		$this->setVar('multi',true);
		return $f;
	}
 /**
  * The constructor for the Uploadify field. Sets some more default settings that require
  * logic, e.g. upload_max_filesize.
  *
  * @param string $name The name of the field. For single files, omit the "ID" and use
  * 					   just the relation name
  * @param string $title The label for the field
  * @param array $configuration Some extra confuguration settings to add {@see setVar}
  * @param Form $form The parent form to this field
  */
 public function __construct($name, $title = null, $configuration = array(), $form = null)
 {
     parent::__construct($name, $title, null, $form);
     // A little hack to make things easier in the CMS
     $controller = Director::urlParam('Controller');
     if (is_subclass_of($controller, "LeftAndMain")) {
         self::$backend = true;
     }
     $this->setVar('sizeLimit', self::convert_bytes(ini_get('upload_max_filesize')));
     $this->setVar('buttonText', _t('Uploadify.BUTTONTEXT', 'Browse...'));
     $this->addParam('PHPSESSID', session_id());
     $this->setVar('queueID', 'UploadifyFieldQueue_' . $this->Name());
     if ($this->Backend()) {
         $this->template .= "Backend";
     }
     foreach ($configuration as $key => $val) {
         $this->setVar($key, $val);
     }
 }
 /**
  * Load the requirements and return a formfield to the template. Ensure "multi" is off.
  *
  * @return UploadifyField
  */
 public function FieldHolder()
 {
     $f = parent::FieldHolder();
     $this->setVar('multi', false);
     return $f;
 }