How to add a txt file and create a ZIP in php
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/2286639/open-file-write-to-file-save-file-as-a-zip-and-stream-to-user-for-download">Open file, write to file, save file as a zip and stream to user for download</a>  </p>
</blockquote>



<p>I have a txt file  in uploads folder where i need to add this file  and create a ZIP on fly and prompt the user to download the Zip file which should contain the text file .How do i do this and moreover what are the headers needed for prompting the user for download .can any one Help me out. I have used the same  constucts from PHP Manual.Iam Using the same function to zip  the file      "http://davidwalsh.name/create-zip-php" and iam writing this code and iam getting prompted for zip download but iam getting the caution message  when i extarct the file </p>

<pre><code>$zip_file = "my-archive.zip";
$file_path="../../../downloads/";
$files_to_zip = array($file_path."test_testing.txt");
$result = create_zip($files_to_zip,'my-archive.zip');

header('Content-Description: File Transfer');    
header('Content-Transfer-Encoding: binary');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); 
header("Content-type: application/zip");
header("Content-Disposition: attachment; filename=".$zip_file);
header("Pragma: no-cache");
header("Expires: 0");

readfile($zip_file);    
</code></pre>

<p>The Caution error message is "one or more files in this archive uses ".."(parent folder) as part of its folder information "</p>
