Commit ff930d45 authored by Tino Goratsch's avatar Tino Goratsch

the Upload::moveFile() method now attempts to create the desired upload folder...

the Upload::moveFile() method now attempts to create the desired upload folder by itself if it doesn't exists
parent 32c3e6b6
......@@ -2,6 +2,7 @@
namespace ACP3\Core\Helpers;
use ACP3\Core\Environment\ApplicationPath;
use ACP3\Core\Validation\Exceptions\ValidationFailedException;
/**
* Class Upload
......@@ -37,14 +38,24 @@ class Upload
* Temporäre Datei
* @param string $filename
* Dateiname
* @param bool $retainFilename
*
* @param bool $retainFilename
* @return array
* @throws ValidationFailedException
*/
public function moveFile($tmpFilename, $filename, $retainFilename = false)
{
$path = $this->appPath->getUploadsDir() . $this->directory . '/';
if (!is_dir($path)) {
$result = @mkdir($path);
if (!$result) {
throw new ValidationFailedException(
[sprintf('Could not create folder "%s"', $this->directory)]
);
}
}
if ($retainFilename === true) {
$newFilename = $filename;
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment