Fire hooks for mkdir for folder upload

fromTmpFile function, usual mkdir call is only working for file's parent
directory. Does not care upper parent folders. I added a recursive
function that creates parent non-existing folders with usual mkdir.
This commit is contained in:
karakayasemi 2016-06-21 17:10:52 +02:00 committed by Vincent Petry
parent cab7106dfb
commit c8b7a059b4
No known key found for this signature in database
GPG Key ID: AF8F9EFC56562186
1 changed files with 22 additions and 1 deletions

View File

@ -998,7 +998,10 @@ class View {
// Create the directories if any
if (!$this->file_exists($filePath)) {
$this->mkdir($filePath);
$result = $this->createParentDirectories($filePath);
if($result === false) {
return false;
}
}
$source = fopen($tmpFile, 'r');
@ -2107,4 +2110,22 @@ class View {
}
return [$uid, $filename];
}
/**
* Creates parent non-existing folders
*
* @param string $filePath
* @return bool
*/
private function createParentDirectories($filePath) {
$parentDirectory = dirname($filePath);
while(!$this->file_exists($parentDirectory)) {
$result = $this->createParentDirectories($parentDirectory);
if($result === false) {
return false;
}
}
$this->mkdir($filePath);
return true;
}
}