I've php script for creating zip folder of some text files
<?php
$path = "path\to\files";
$files = array($path.'\ionic interaction.txt',$path.'\file1.txt',$path.'\file2.txt',$path.'\file3.txt',$path.'\file3.txt');
$folder = $_POST['filename'];
$zipname = $folder.'.zip';
echo '<form action="download.php" method="post" name="zippass2download"><input type="hidden" name="zipname" value="'.$zipname.'"></form>';
$zip = new ZipArchive;
$zip -> open($zipname, ZipArchive::CREATE);
foreach($files as $file)
{
$zip -> addFile($file);
}
$zip -> close();
?>
Next to that script I've created a hyperlink to download the zip folder created in the first script.
<a href="download.php">Download</a>
In download.php I've following codes
<?php
$path2zip = 'C:/wamp/www/PPInt';
$tobezipped = $_POST['zipname'];
header('Content-disposition: attachment; filename=$tobezipped');
header('Content-type: application/zip');
readfile('$path2zip/$tobezipped');
?>
Not getting where is the problem. Can anyone solve this for me?
<form>
– Gerald Schneider