Ich benutze Laravel 4.2 und suche einen Bereich, in dem eine Zip-Datei erstellt wird, die der Benutzer herunterladen kann.Zip erstellen und Herunterladen erzwingen - Laravel
Ich erhalte den Fehler
Die Datei "myzip.zip existiert nicht"
Mein aktueller Code ist:
// 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);
Kann mir jemand helfen, wie zu Warum bekomme ich den Fehler nicht existiert?
Vielen Dank!
Wenn Sie Ihr Verzeichnis über ftp überprüfen, ist die zip erstellt oder nicht? –
Haben Sie eine Lösung für dieses Problem gefunden? Ich stehe vor demselben Problem. –