PHP has a lot of file directory functions, you can copy files, delete files. But sometimes because the copy file is too large, it can cause a program error.
<?php
Header ("Content-type:text/html;charset=utf-8");
Programme one:
$rs = file_get_contents ("1.flv");
File_put_contents ("2.flv", $rs);
? >
For example, this file 1.flv is a video file, his memory will occupy a lot of, there will be a hundreds of trillion, will generally exceed the PHP default memory. PHP's default memory is in php.ini.
My default is 128M, of course this can set itself, Ini_set (' Memory_limit ', ' 128M '); Reset PHP can use the memory size of 128M, but generally on the remote host is not able to modify the php.ini file, only through program settings. Note: Under Safe_mode (Safe mode), the Ini_set is invalid.
Then we can use this procedure at this time.
<?php
Header ("Content-type:text/html;charset=utf-8");
Programme II:
$SRC = fopen ("1.flv", "R");
$des = fopen ("2.flv", "w");
while ($str = Fread ($SRC, 4096)) {
fwrite ($des, $str);
Fclose ($des);
Fclose ($SRC);
echo "-------";
? >
Scenario two we use a loop that writes only 4M at a time. This will not have a memory overflow problem.