mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
API Default to Upload::$uploads_dir in UploadField
This commit is contained in:
parent
e20f15df55
commit
d487a42456
@ -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) {
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user