Fixed move_uploaded_file bullshit
This commit is contained in:
parent
42b8049ae5
commit
cd437ca036
2 changed files with 16 additions and 9 deletions
|
@ -6,12 +6,25 @@ class ApiFileInput
|
|||
{
|
||||
public $filePath;
|
||||
public $fileName;
|
||||
public $originalPath;
|
||||
|
||||
public function __construct($filePath, $fileName)
|
||||
{
|
||||
//todo: move_uploaded_file here
|
||||
//concerns post thumbs and post content
|
||||
$this->filePath = $filePath;
|
||||
$tmpPath = tempnam(sys_get_temp_dir(), 'upload') . '.dat';
|
||||
$this->originalPath = $tmpPath;
|
||||
|
||||
//php "security" bullshit
|
||||
if (is_uploaded_file($filePath))
|
||||
move_uploaded_file($filePath, $tmpPath);
|
||||
else
|
||||
copy($filePath, $tmpPath);
|
||||
|
||||
$this->filePath = $tmpPath;
|
||||
$this->fileName = $fileName;
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
TransferHelper::remove($this->originalPath);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,8 +106,6 @@ class PostController
|
|||
$jobArgs[EditPostContentJob::POST_CONTENT] = new ApiFileInput(
|
||||
$file['tmp_name'],
|
||||
$file['name']);
|
||||
|
||||
TransferHelper::remove($file['tmp_name']);
|
||||
}
|
||||
|
||||
Api::run(new AddPostJob(), $jobArgs);
|
||||
|
@ -150,8 +148,6 @@ class PostController
|
|||
$jobArgs[EditPostContentJob::POST_CONTENT] = new ApiFileInput(
|
||||
$file['tmp_name'],
|
||||
$file['name']);
|
||||
|
||||
TransferHelper::remove($file['tmp_name']);
|
||||
}
|
||||
|
||||
if (!empty($_FILES['thumb']['name']))
|
||||
|
@ -162,8 +158,6 @@ class PostController
|
|||
$jobArgs[EditPostThumbJob::THUMB_CONTENT] = new ApiFileInput(
|
||||
$file['tmp_name'],
|
||||
$file['name']);
|
||||
|
||||
TransferHelper::remove($file['tmp_name']);
|
||||
}
|
||||
|
||||
Api::run(new EditPostJob(), $jobArgs);
|
||||
|
|
Loading…
Reference in a new issue