Re: Downloading strangeness: downloaded file has no content
Jerry Stuckle <[email protected]>
| Newsgroups | comp.lang.php |
|---|---|
| Organization | A noiseless patient Spider |
| Message-ID | <[email protected]> |
On 10/1/2022 10:50 AM, Tim Streater wrote:
> For those requesting that a file be downloaded from my website, having
> selected a file (a .zip or a .dmg), the following is then executed:
>
> <font color="#000000">header('Content-Description: File Transfer');</font>
> header('Content-Type: application/octet-stream');
> header('Content-Disposition: attachment; filename="' . basename ($file) .
> '"');
> header('Content-Transfer-Encoding: binary');
> header('Expires: 0');
> header('Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0');
> header('Pragma: public');
> header('Content-Length: ' . filesize ($file));
>
> ob_clean ();
> flush ();
> readfile ($file);
>
>
> For most of the files to be downloaded, this works just fine. But for one of
> them, the downloaded file has zero content at the receiver's end: it is zero
> bytes long. The file on the server is correct - I can download it using an FTP
> client and drag/drop the file off the server and onto my desktop. Then it has
> the correct size/content.
>
> Any suggestions as to why this might be?
>
Tim,
What's in your PHP error log? It's always the first place I check when
I have weird problems.
Have you checked the contents of $file? Is it correct - including the
path? What is the result of filesize($file)? What are the ownership
and permissions on the file? Does the web server have read access to it?
--
==================
Remove the "x"'s from my email address
Jerry Stuckle
[email protected]
==================