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 $filePath;
|
||||||
public $fileName;
|
public $fileName;
|
||||||
|
public $originalPath;
|
||||||
|
|
||||||
public function __construct($filePath, $fileName)
|
public function __construct($filePath, $fileName)
|
||||||
{
|
{
|
||||||
//todo: move_uploaded_file here
|
$tmpPath = tempnam(sys_get_temp_dir(), 'upload') . '.dat';
|
||||||
//concerns post thumbs and post content
|
$this->originalPath = $tmpPath;
|
||||||
$this->filePath = $filePath;
|
|
||||||
|
//php "security" bullshit
|
||||||
|
if (is_uploaded_file($filePath))
|
||||||
|
move_uploaded_file($filePath, $tmpPath);
|
||||||
|
else
|
||||||
|
copy($filePath, $tmpPath);
|
||||||
|
|
||||||
|
$this->filePath = $tmpPath;
|
||||||
$this->fileName = $fileName;
|
$this->fileName = $fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function __destruct()
|
||||||
|
{
|
||||||
|
TransferHelper::remove($this->originalPath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,8 +106,6 @@ class PostController
|
||||||
$jobArgs[EditPostContentJob::POST_CONTENT] = new ApiFileInput(
|
$jobArgs[EditPostContentJob::POST_CONTENT] = new ApiFileInput(
|
||||||
$file['tmp_name'],
|
$file['tmp_name'],
|
||||||
$file['name']);
|
$file['name']);
|
||||||
|
|
||||||
TransferHelper::remove($file['tmp_name']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Api::run(new AddPostJob(), $jobArgs);
|
Api::run(new AddPostJob(), $jobArgs);
|
||||||
|
@ -150,8 +148,6 @@ class PostController
|
||||||
$jobArgs[EditPostContentJob::POST_CONTENT] = new ApiFileInput(
|
$jobArgs[EditPostContentJob::POST_CONTENT] = new ApiFileInput(
|
||||||
$file['tmp_name'],
|
$file['tmp_name'],
|
||||||
$file['name']);
|
$file['name']);
|
||||||
|
|
||||||
TransferHelper::remove($file['tmp_name']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($_FILES['thumb']['name']))
|
if (!empty($_FILES['thumb']['name']))
|
||||||
|
@ -162,8 +158,6 @@ class PostController
|
||||||
$jobArgs[EditPostThumbJob::THUMB_CONTENT] = new ApiFileInput(
|
$jobArgs[EditPostThumbJob::THUMB_CONTENT] = new ApiFileInput(
|
||||||
$file['tmp_name'],
|
$file['tmp_name'],
|
||||||
$file['name']);
|
$file['name']);
|
||||||
|
|
||||||
TransferHelper::remove($file['tmp_name']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Api::run(new EditPostJob(), $jobArgs);
|
Api::run(new EditPostJob(), $jobArgs);
|
||||||
|
|
Loading…
Reference in a new issue