我已经使用此代码将45 MB的zip文件从A服务器复制到B服务器。将大型文件从服务器下载或复制到服务器
<?php
set_time_limit(0);
$file = 'https://www.xxxxx.com/Products.zip';
$newfile = 'Products.zip';
if (copy($file, $newfile)) {
echo "Copy success!";
}else{
echo "Copy failed.";
}
?>
复制17 MB后它给服务器错误。
我用一些其他的代码一样
<?php
set_time_limit(0);
$url = 'https://www.mydomaind.com/Products.zip';
$path = 'Products.zip';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);
curl_close($ch);
file_put_contents($path, $data);
echo 'done';
?>
另外一个
<?php
set_time_limit(0);
$source =("https://www.mydomaind.com/Products.zip");
$destination = 'Produtcs.zip';
$data = file_get_contents($source);
$handle = fopen($destination, "w");
fwrite($handle, $data);
fclose($handle);
echo 'done';
?>
这些最后的轻松下载或从服务器复制到服务器代码下载或复制文件,如5 MB。 但是,如果需要50 MB的同一工作。给出错误。
请帮我怎么做。 谢谢
“它给错误halp”不是PHP抛出的有效错误消息。 – PeeHaa
我得到500内部服务器错误 – lospicos