远程下载和存储文件
Download and storing file remotelly
我正在尝试下载远程 xml 文件,但无法正常工作,因为我没有将文件存储在我的存储器中。
我的代码:
$url = 'http://xml.url.xml';
set_time_limit(0);
// Download file and save it on folder
$guzzleClient = new Client();
$response = $guzzleClient->get($url);
$body = $response->getBody();
$body->seek(0);
$size = $body->getSize();
$file = $body->read($size);
Storage::download($file);
Storage::download()
方法用于生成响应,在浏览器中强制下载。
改用Storage::put('filename.xml', $content)
。
您可以在文档中阅读更多内容:
我正在尝试下载远程 xml 文件,但无法正常工作,因为我没有将文件存储在我的存储器中。
我的代码:
$url = 'http://xml.url.xml';
set_time_limit(0);
// Download file and save it on folder
$guzzleClient = new Client();
$response = $guzzleClient->get($url);
$body = $response->getBody();
$body->seek(0);
$size = $body->getSize();
$file = $body->read($size);
Storage::download($file);
Storage::download()
方法用于生成响应,在浏览器中强制下载。
改用Storage::put('filename.xml', $content)
。
您可以在文档中阅读更多内容: