本文介紹了Laravel 5 多重下載文件的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
如果我在 127.0.0.1/load/files 打開瀏覽器,此代碼將正常工作.(自動下載文件)
This code will work correctly if I open browser at 127.0.0.1/load/files. (Auto Download File)
ABCController.php
namespace AppHttpControllers;
use Response;
use File;
function download_file(){
return Response::download(public_path() . "/files/file_1.txt");
}
routes.php
Route::get('/load/files','ABCController@download_file');
我可以使用 1 個路徑和 1 個功能同時下載 2 個文件嗎?比如
Can I use 1 route and 1 function for download 2 files at the same time ? Such as
function download_file(){
return Response::download(["file_1.txt","file_2.txt"]); //this code not right
}
感謝您的幫助.
推薦答案
使用 HTTP 協議通過同一個請求同時發送多個文件是不可能的.Laravel 也不支持這一點.例如,您必須將文件打包成 zip 文件.
It is not possible to send more than one file simultaneously over the same request with the HTTP protocol. Laravel also does not support this. You have to pack the files in, for example, a zip file.
另見
- 在 php 中以 zip 格式下載多個文件
- Zipper(一個方便的 ZipArchive 包裝器)
- download multiple files as zip in php
- Zipper (a handy wrapper for ZipArchive)
這篇關于Laravel 5 多重下載文件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!