szurubooru/src/Api/ApiFileInput.php

31 lines
611 B
PHP
Raw Normal View History

<?php
/**
* Used for serializing files passed in POST requests to job arguments
*/
class ApiFileInput
{
public $filePath;
public $fileName;
2014-05-06 19:39:26 +02:00
public $originalPath;
public function __construct($filePath, $fileName)
{
2014-05-06 19:39:26 +02:00
$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;
}
2014-05-06 19:39:26 +02:00
public function __destruct()
{
TransferHelper::remove($this->originalPath);
}
}