Forum Moderators: coopster
here is a quick snippit...code started in browser, but ive tried to dull it down and run in shell to help debug and not worry about header issues...
function download ($file_source, $file_target)
{
// Preparations
$file_source = str_replace(' ', '%20', html_entity_decode($file_source)); // fix url format
if (file_exists($file_target)) { chmod($file_target, 0777); } // add write permission
// Begin transfer
if (($rh = fopen($file_source, 'rb')) === FALSE) { return false; } // fopen() handles
if (($wh = fopen($file_target, 'wb')) === FALSE) { return false; } // error messages.
$test = 0;
$filesize = filesize($rh);
echo($filesize);
echo($file_source);
while (!feof($rh))
{
$test = $test + 1024;
fread($rh, 1024);
}
*THE FILE FROM THE ABOVE ALWAYS STOPS AROUND 30 mb or so, but in bytes obvioulsy...***writing seems fine
echo($test);
fwrite($wh, $rh);
echo("after");
fclose($rh);
fclose($wh);
return true;
}
print "asdfasdf";
$videourl = "http://www.example.com/whatever.mpg";
echo $videourl;
$randname = rand(1000000, 9999999);
$ext2 = substr(strrchr($videourl, '.'), 1);
//$ext2 = substr(strrchr($videourl, '.'));
$randname .= ".".$ext2;
$temp_dir = "/home/user/www/whatever.mpg";
download($videourl, $temp_dir);
****
THis is how I had read/write combined in above code before I seperated and isolated to the read just fyi
while (!feof($rh))
{
if (fwrite($wh, fread($rh, 1024)) === FALSE) { fclose($rh); fclose($wh); return false; }
}
****
*left the echos in so you can see the data points
thanks!
It seems to be a memory issue. Are you getting any error messages?
[webmasterworld.com...]