芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/www/vendor/livewire/livewire/src/RenameMe/SupportFileDownloads.php
valueIsntAFileResponse($returned)) return; $response = $returned; $name = $this->getFilenameFromContentDispositionHeader( $response->headers->get('Content-Disposition') ); $binary = $this->captureOutput(function () use ($response) { $response->sendContent(); }); $content = base64_encode($binary); $this->downloadsById[$component->id] = [ 'name' => $name, 'content' => $content, ]; $component->skipRender(); }); Livewire::listen('component.dehydrate.subsequent', function ($component, $response) { if (! $download = $this->downloadsById[$component->id] ?? false) return; $response->effects['download'] = $download; }); } function valueIsntAFileResponse($value) { return ! $value instanceof StreamedResponse && ! $value instanceof BinaryFileResponse; } function captureOutput($callback) { ob_start(); $callback(); return ob_get_clean(); } function getFilenameFromContentDispositionHeader($header) { /** * The following conditionals are here to allow for quoted and * non quoted filenames in the Content-Disposition header. * * Both of these values should return the correct filename without quotes. * * Content-Disposition: attachment; filename=filename.jpg * Content-Disposition: attachment; filename="test file.jpg" */ if (preg_match('/.*?filename="(.+?)"/', $header, $matches)) { return $matches[1]; } if (preg_match('/.*?filename=([^; ]+)/', $header, $matches)) { return $matches[1]; } return 'download'; } }