API Default to Upload::$uploads_dir in UploadField

This commit is contained in:
Nathan J. Brauer 2012-12-19 17:52:44 -08:00 committed by Ingo Schommer
parent e20f15df55
commit d487a42456
2 changed files with 6 additions and 6 deletions

View File

@ -64,11 +64,11 @@ class FileField extends FormField {
/**
* Partial filesystem path relative to /assets directory.
* Defaults to 'Uploads'.
* Defaults to Upload::$uploads_folder.
*
* @var string
*/
protected $folderName = 'Uploads';
protected $folderName = false;
/**
* Create a new file field.
@ -111,7 +111,7 @@ class FileField extends FormField {
$file = new $fileClass();
}
$this->upload->loadIntoFile($_FILES[$this->name], $file, $this->folderName);
$this->upload->loadIntoFile($_FILES[$this->name], $file, $this->getFolderName());
if($this->upload->isError()) return false;
$file = $this->upload->getFile();
@ -160,7 +160,7 @@ class FileField extends FormField {
* @return string
*/
public function getFolderName() {
return $this->folderName;
return ($this->folderName !== false) ? $this->folderName : Upload::$uploads_folder;
}
public function validate($validator) {

View File

@ -431,7 +431,7 @@ class UploadField extends FileField {
* @return UploadField_ItemHandler
*/
public function handleSelect(SS_HTTPRequest $request) {
return UploadField_SelectHandler::create($this, $this->folderName);
return UploadField_SelectHandler::create($this, $this->getFolderName());
}
/**
@ -500,7 +500,7 @@ class UploadField extends FileField {
// Get the uploaded file into a new file object.
try {
$this->upload->loadIntoFile($tmpfile, $fileObject, $this->folderName);
$this->upload->loadIntoFile($tmpfile, $fileObject, $this->getFolderName());
} catch (Exception $e) {
// we shouldn't get an error here, but just in case
$return['error'] = $e->getMessage();