szurubooru/src/Api/ApiFileInput.php
2014-05-07 17:58:23 +02:00

30 lines
611 B
PHP

<?php
/**
* Used for serializing files passed in POST requests to job arguments
*/
class ApiFileInput
{
public $filePath;
public $fileName;
public $originalPath;
public function __construct($filePath, $fileName)
{
$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);
}
}