1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00
invoiceninja/app/Utils/TempFile.php

36 lines
802 B
PHP
Raw Normal View History

<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Utils;
class TempFile
{
public static function path($url) :string
{
2021-01-12 00:21:17 +01:00
$temp_path = @tempnam(sys_get_temp_dir() . '/' . sha1(time()), basename($url));
copy($url, $temp_path);
return $temp_path;
}
2021-02-11 04:43:48 +01:00
/* Downloads a file to temp storage and returns the path - used for mailers */
public static function filePath($data) :string
{
$file_path = sys_get_temp_dir().'/'.sha1(microtime());
file_put_contents($file_path, $data);
return $file_path;
}
}