From 0d2e2eb494e0eddc03eda7dfa9034c5ccd66c0e2 Mon Sep 17 00:00:00 2001 From: aina-esokia Date: Thu, 28 Jun 2018 17:32:57 +0400 Subject: [PATCH] use tmp_files on upload file --- .../Phrasea/Controller/Prod/UploadController.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/Alchemy/Phrasea/Controller/Prod/UploadController.php b/lib/Alchemy/Phrasea/Controller/Prod/UploadController.php index a56c7d957a..47e6716ac4 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/UploadController.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/UploadController.php @@ -128,7 +128,20 @@ class UploadController extends Controller try { // Add file extension, so mediavorus can guess file type for octet-stream file $uploadedFilename = $file->getRealPath(); - $renamedFilename = $file->getRealPath() . '.' . pathinfo($file->getClientOriginalName(), PATHINFO_EXTENSION); + $renamedFilename = null; + + if(!empty($this->app['conf']->get(['main', 'storage', 'tmp_files']))){ + $tmpStorage = \p4string::addEndSlash($this->app['conf']->get(['main', 'storage', 'tmp_files'])).'upload/'; + + if(!is_dir($tmpStorage)){ + $this->getFilesystem()->mkdir($tmpStorage); + } + + $renamedFilename = $tmpStorage. pathinfo($file->getRealPath(), PATHINFO_FILENAME) .'.' . pathinfo($file->getClientOriginalName(), PATHINFO_EXTENSION); + + }else{ + $renamedFilename = $file->getRealPath() . '.' . pathinfo($file->getClientOriginalName(), PATHINFO_EXTENSION); + } $this->getFilesystem()->rename($uploadedFilename, $renamedFilename);