PHP copy()最大大小问题

I transferred a download script onto my QNAP today from my publish server, which basically uses copy() to download a video from a URL. For some reason any video I download comes out at exactly 33,378,304 bytes. My php.ini file is set to 3600 timeout and it does not make a bit of difference, anyone else had this problem?

When I run the script directly using

# php <script path>

The php.ini is ignored and the full file is downloaded, there must be a line I'm missing in the config.

Any help would be greatly appreciated, thanks!

upload_max_filesize is set to 2047M

This is a work-around rather than a solution to the problem but have you tried using exec("cp $src $dst") or system("cp $src $dst")

as far as I can see there is no limit for the copy() command in PHP which makes this a strange bug.

Have you changed the post_max_size value too?

-

EDIT

Some video servers protect themselves by forbidding the download of more than a specific portion of the video (I already the same issue while trying to download video streams).

As a workaround, you can use this script to download the video piece by piece:

function fragmented_download($url, $destination)
{
    $headers = get_headers($url, 1);
    $downloadsize = $headers["Content-Length"];
    for ($filesize = 0 ; $filesize < $downloadsize ; $filesize = filesize($destination))
    {
        exec("wget --continue --output-document='$destination' '$url'");
    }
}