KingOfHeart Posted November 8, 2009 Share Posted November 8, 2009 I want to use a php script to create two files. Then I want it to redirect (or whatever) to have those files download together. Can I have it download a folder? Or maybe have it create a zip/rar file and add those files in the zip/rar? So what options do I have? Quote Link to comment https://forums.phpfreaks.com/topic/180798-solved-php-and-downloading/ Share on other sites More sharing options...
trq Posted November 9, 2009 Share Posted November 9, 2009 You would need to create an archive of some type. See here. Quote Link to comment https://forums.phpfreaks.com/topic/180798-solved-php-and-downloading/#findComment-953971 Share on other sites More sharing options...
KingOfHeart Posted November 9, 2009 Author Share Posted November 9, 2009 I tried to use one of their scripts but I get this error. "Fatal error: Call to undefined function: bzopen() in /home/thegamin/public_html/openzelda/zeldaminer.php on line 301" function compile() { $in = "temp.php"; $out = "Download/ZMinerLevel.zip"; if (!file_exists ($in) || !is_readable ($in)) return false; if ((!file_exists ($out) && !is_writeable (dirname ($out)) || (file_exists($out) && !is_writable($out)) )) return false; $in_file = fopen ($in, "rb"); $out_file = bzopen ($out, "wb"); while (!feof ($in_file)) { $buffer = fgets ($in_file, 4096); bzwrite ($out_file, $buffer, 4096); } fclose ($in_file); bzclose ($out_file); return true; } I can use the php version "4.4.8" and "5.2.5" before you start the problem has to do with the version. Quote Link to comment https://forums.phpfreaks.com/topic/180798-solved-php-and-downloading/#findComment-954234 Share on other sites More sharing options...
trq Posted November 9, 2009 Share Posted November 9, 2009 Seems you don't have bzip2 installed. Quote Link to comment https://forums.phpfreaks.com/topic/180798-solved-php-and-downloading/#findComment-954350 Share on other sites More sharing options...
newbtophp Posted November 10, 2009 Share Posted November 10, 2009 <?php $zip = new ZipArchive; //zip name if ($zip->open('test.zip') === TRUE) { //files to add to the zip $zip->addFile('/path/to/index.txt', 'newname.txt'); $zip->close(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/180798-solved-php-and-downloading/#findComment-954480 Share on other sites More sharing options...
KingOfHeart Posted November 13, 2009 Author Share Posted November 13, 2009 I used php5 because I got an error about the class ZipArchive. It says "file not found" In the same folder as this php file I have a file named test.zip and test.txt <? $zip = new ZipArchive; //zip name if ($zip->open('test.zip') === TRUE) { //files to add to the zip $zip->addFile('test.txt', 'newname.txt'); $zip->close(); } else echo "File not found"; ?> I'm checking php.net to see if I can figure this out myself a while. Quote Link to comment https://forums.phpfreaks.com/topic/180798-solved-php-and-downloading/#findComment-956606 Share on other sites More sharing options...
KingOfHeart Posted November 13, 2009 Author Share Posted November 13, 2009 Wait, found out why I got an error. When I tried to create the file on the website it did not create it properly, I had to upload instead. Quote Link to comment https://forums.phpfreaks.com/topic/180798-solved-php-and-downloading/#findComment-956608 Share on other sites More sharing options...
KingOfHeart Posted November 15, 2009 Author Share Posted November 15, 2009 I have one small issue. I got the script to perfectly update the zip file on the website. However, whenever I try to download it, the zip is blank. $zip = new ZipArchive; $res = $zip->open('zminer/LevelSource.zip', ZIPARCHIVE::OVERWRITE); if ($res === TRUE) { $zip->addFile('zminer/level.lnd', 'level.lnd'); $zip->close(); echo "<a href = 'zminer/LevelSource.zip'>Download Source</a>"; } How can I get it to download it properly? Quote Link to comment https://forums.phpfreaks.com/topic/180798-solved-php-and-downloading/#findComment-957776 Share on other sites More sharing options...
KingOfHeart Posted November 15, 2009 Author Share Posted November 15, 2009 http://openzelda.thegaminguniverse.com/zeldaminer.php?id=15 You can choose to download source, just in case if it's another issue. After all I don't see why it would update the ftp, and not the actual file. Quote Link to comment https://forums.phpfreaks.com/topic/180798-solved-php-and-downloading/#findComment-957808 Share on other sites More sharing options...
KingOfHeart Posted November 19, 2009 Author Share Posted November 19, 2009 Well for some reason I have a cache problem(kind of figured). So to help resolve this, I added in a "copy" so I can rename the zip. I guess I'll rename it by file and time. So I'll call this solved. Quote Link to comment https://forums.phpfreaks.com/topic/180798-solved-php-and-downloading/#findComment-961533 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.