src/FileUtil.php
public static function saveInputAsFile($content, $tmpDir = '', $key = '')
    {
        if (!$tmpDir) {
            $tmpDir = ini_get('upload_tmp_dir');
        }
        if (!is_dir($tmpDir)) {
            return false;
        }
        if (!$key) {
            $key = uniqid();
        }
        if (!$content) {
            return false;
        }
        $tmp_file = realpath($tmpDir) . '/' . $key;
        if (self::create($tmp_file, $content) > 0) {
            return ['name' => $key, 'path' => $tmp_file];
        } else {
            return false;
        }
    }
public static function saveInputAsFile($content, $tmpDir = '', $key = '')
    {
        if (!$tmpDir) {
            $tmpDir = ini_get('upload_tmp_dir');
        }
        if (!is_dir($tmpDir)) {
            return false;
        }
        if (!$key) {
            $key = uniqid();
        }
        if (!$content) {
            return false;
        }
        $tmp_file = realpath($tmpDir) . '/' . $key;
        if (self::create($tmp_file, $content) > 0) {
            return ['name' => $key, 'path' => $tmp_file];
        } else {
            return false;
        }
    }
public static function saveInputAsFile ( $ content , $ tmpDir = '' , $ key = '' ) { if ( ! $ tmpDir ) { $ tmpDir = ini_get ( 'upload_tmp_dir' ) ; } if ( ! is_dir ( $ tmpDir ) ) { return false ; } if ( ! $ key ) { $ key = uniqid ( ) ; } if ( ! $ content ) { return false ; } $ tmp_file = realpath ( $ tmpDir ) . '/' . $ key ; if ( self :: create ( $ tmp_file , $ content ) > 0 ) { return [ 'name' => $ key , 'path' => $ tmp_file ] ; } else { return false ; } }
put the format php input stream into the temporary file.

return [
['name'=>'file name','path'=>'/var/cache/a.txt']
];
@param $content string
@param $tmpDir string
@param $key string
@return array|bool
@throws \Exception
put the format php input stream into the temporary file .