herghost Posted January 8, 2012 Share Posted January 8, 2012 Hi all My script now works, and the files are added to the zip, however the 1st two directories in my zip are 'uploads' and then the username, basically I want the zipped files to start from within the users directory and I just cant figure out what I need to do, any help would be greatly appreciated, been looking at these 30 odd lines for 6 hours //make zip $sourcefolder = "uploads/".$username.""; $zipfilename = "uploads/".$username.".zip"; $timeout = 5000; $dirlist = new RecursiveDirectoryIterator($sourcefolder); $filelist = new RecursiveIteratorIterator($dirlist); ini_set('max_execution_time', $timeout); $zip = new ZipArchive(); if ($zip->open("$zipfilename", ZipArchive::CREATE) !== TRUE) { die ("Could not open archive"); } foreach ($filelist as $key=>$value) { $zip->addFile(realpath($key), $key) or die ("ERROR: Could not add file: $key"); } $zip->close(); echo "<br>Archive ". $zipfilename . " created successfully."; ?> <br /><a href="http:<?php echo $zipfilename;?>" target="_blank"> Download <?php echo $zipfilename?></a> Quote Link to comment https://forums.phpfreaks.com/topic/254584-further-php-zip-help/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.