Tôi đang sử dụng Laravel 4.2 và đang tìm cách thiết lập khu vực nơi tệp zip được tạo để người dùng tải xuống.Tạo Zip và Force Tải xuống - Laravel
tôi tiếp tục nhận được lỗi
Các tập tin "myzip.zip không tồn tại"
mã hiện tại của tôi là:
// Here we choose the folder which will be used.
$dirName = public_path() . '/uploads/packs/'.$pack_id;
// Choose a name for the archive.
$zipFileName = 'myzip.zip';
// Create "MyCoolName.zip" file in public directory of project.
$zip = new ZipArchive;
if ($zip->open(public_path() . '/' . $zipFileName, ZipArchive::CREATE) === true)
{
// Copy all the files from the folder and place them in the archive.
foreach (glob($dirName . '/*') as $fileName)
{
$file = basename($fileName);
$zip->addFile($fileName, $file);
}
$zip->close();
$headers = array(
'Content-Type' => 'application/octet-stream',
);
// Download .zip file.
return Response::download(public_path() . '/' . $zipFileName, $zipFileName, $headers);
thể bất cứ ai giúp tôi, Như để tại sao tôi nhận được lỗi không tồn tại?
Cảm ơn bạn!
Nếu bạn kiểm tra thư mục của bạn thông qua ftp, là zip tạo hay không? –
Bạn có tìm thấy giải pháp nào cho vấn đề này không? Tôi đang phải đối mặt với vấn đề tương tự. –