I need to create, zip, download and delete a file in one request in Laravel. I use the following code in my controller:
$pathToFile = "myFile.txt";
$content = "content";
Storage::put($pathToFile,$content);
$file = storage_path().'/app/'.$pathToFile;
$zipFile = storage_path().'/app/'.$this->name.'.zip';
Zipper::make($zipFile)->add($file);
return response()->download($zipFile);
Unfortunately the zip file is not created at the time I try to download it. Therefore I got an error that the file does not exists. However after the error response the file is created and it is available. So if I run the same controller method again, the file is downloaded.
Could you please help me with this issue. I would like to be able to create the file, to download it and delete it.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1rYfOFY
via IFTTT
Aucun commentaire:
Enregistrer un commentaire