Commit ed5f9795 authored by jiangkebao's avatar jiangkebao

文件流下载

parent 1d22a338
......@@ -849,4 +849,26 @@ if (!function_exists('download_file')) {
}
return $path . '/' . $filename;;
}
}
if (!function_exists('download_file_stream')) {
/**文件流保存到本地
* @param $fileStream 文件流
* @param null $path 保存路径
* @return string
*/
function download_file_stream($fileStream, $path = null)
{
$root = config('server.settings.document_root', BASE_PATH . '/public');
$path = $path ? $path : '/download/files';
$savePath = $root . $path;
if (!is_dir($savePath)) {
// 判断路径是否存在,不存在,则创建
mkdir($savePath, 0777, true);
}
$fileName = '/' . date('YmdHis') . 'track' . '.pdf';
file_put_contents($savePath . $fileName, base64_decode($fileStream), 1);
return $path . $fileName;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment