Bruce Gust
asked on
Why is this zip file empty?
I've got a link that looks like this: http://loosecannonfitness.com/downloads.php?email=bruce@brucegust.com
It hits that page and, provided it gets appropriately validated, it hits this code:
The "update" part works great and I get the box that asks if I want to save or open the zip file. The problem is, although I can look at my server and see the "1775.zip" file that's over 22MB, when I go to download it, it's 0 bytes.
In other words, everything seems to be in place except for the content of the file.
What am I doing wrong?
It hits that page and, provided it gets appropriately validated, it hits this code:
$michelle_row=mysqli_fetch_assoc($michelle_query);
$vivian="update hammons set download_success='Y' where email='$michelle_row[email]'";
$vivian_query=mysqli_query($cxn, $vivian);
if($michelle_row['workout']=="1775")
{
$filename="1775.zip";
}
else
{
$filename="Devildog.zip";
}
header("Content-Type: application/zip");
header('Content-Disposition: attachment; filename='.$filename);
The "update" part works great and I get the box that asks if I want to save or open the zip file. The problem is, although I can look at my server and see the "1775.zip" file that's over 22MB, when I go to download it, it's 0 bytes.
In other words, everything seems to be in place except for the content of the file.
What am I doing wrong?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you!
It sends the file line-by-line as if it were browser output, written with echo.
ray:
not quite. it acts the same as readfile (which is simpler btw, thanks @insoft for making it one line shorter) or stream copy to stream would act.
they copy the file block by block. the file is moved as fast as the disk and network can handle. the read side is mmapped and the write side is sent to the php output buffer which itself if flushed asynchronously to the webserver's / the system's buffers. in real life, on what i assume to be a lamp server, the file is mmapped by increments of 2 4k blocks at a time and flushed to apache's buffer ( which is large enough to handle the whole file in this case ). this is world's appart more efficient that reading line by line when it comes to zip files.
ASKER
Secondly, there are two questions I have:
If the whole of my script looks like this:
Open in new window
Where does your suggestion belong?
Second question: I'm not familiar fpassthru. I went out to the manual (http://php.net/manual/en/function.fpassthru.php) and found this:
Could you put that in layman's terms and explain to me what that means?
I appreciate you, friend! Glad you're up and running on a Saturday!