Permalink
Browse files

fix path for file; issue #360

  • Loading branch information...
1 parent 4f637db commit 26933866aeef07eb6af584ef0cd524f8f5d0d496 @derdeagle derdeagle committed Feb 12, 2016
Showing with 5 additions and 4 deletions.
  1. +5 −4 generate.php
View
@@ -12,23 +12,24 @@
// check if user opted to zip the generated data
if ($gen->isPromptDownloadZipped()) {
$randNum = mt_rand(0, 100000000);
- $fileName = "./cache/" . $randNum . "_" . $response["promptDownloadFilename"];
+ $fileName = $randNum . "_" . $response["promptDownloadFilename"];
+ $filePath = "./cache/" . $fileName;
$zipPath = "./cache/" . $fileName . ".zip";
- if (file_put_contents($fileName, $response["content"])) {
+ if (file_put_contents($filePath, $response["content"])) {
// now that we've written the file, zip it up
$zip = new ZipArchive();
$zipFile = $zip->open($zipPath, ZipArchive::CREATE);
- if ($zipFile && $zip->addFile($fileName, $response["promptDownloadFilename"])) {
+ if ($zipFile && $zip->addFile($filePath, $response["promptDownloadFilename"])) {
// we've got our zip file now we may set the response header
$zip->close();
header("Content-type: application/zip");
header("Content-Disposition: attachment; filename=" . $response["promptDownloadFilename"] . ".zip");
readfile($zipPath);
unlink($zipPath);
- unlink($fileName);
+ unlink($filePath);
exit;
}
}

0 comments on commit 2693386

Please sign in to comment.