2014-05-03 22:14:00 +02:00
|
|
|
<?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;
|
2014-05-03 22:14:00 +02:00
|
|
|
|
|
|
|
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;
|
2014-05-03 22:14:00 +02:00
|
|
|
$this->fileName = $fileName;
|
|
|
|
}
|
2014-05-06 19:39:26 +02:00
|
|
|
|
|
|
|
public function __destruct()
|
|
|
|
{
|
|
|
|
TransferHelper::remove($this->originalPath);
|
|
|
|
}
|
2014-05-03 22:14:00 +02:00
|
|
|
}
|