mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-01 13:48:37 +02:00
BUG Fixing non-object on file upload
Upload::load() assumes that a parent Folder always exists for a file upload, but that's not always the case, and a non-object error is given if no parent folder. Check the folder exists first before getting the ID.
This commit is contained in:
parent
edb4ecd4d9
commit
68826357cc
@ -159,7 +159,7 @@ class Upload extends Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(file_exists($tmpFile['tmp_name']) && copy($tmpFile['tmp_name'], "$base/$relativeFilePath")) {
|
if(file_exists($tmpFile['tmp_name']) && copy($tmpFile['tmp_name'], "$base/$relativeFilePath")) {
|
||||||
$this->file->ParentID = $parentFolder->ID;
|
$this->file->ParentID = $parentFolder ? $parentFolder->ID : 0;
|
||||||
// This is to prevent it from trying to rename the file
|
// This is to prevent it from trying to rename the file
|
||||||
$this->file->Name = basename($relativeFilePath);
|
$this->file->Name = basename($relativeFilePath);
|
||||||
$this->file->write();
|
$this->file->write();
|
||||||
|
Loading…
Reference in New Issue
Block a user