Jump to content

[SOLVED] php and downloading


KingOfHeart

Recommended Posts

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.

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.

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.