Welcome Guest, Not a member yet? Register   Sign In
How to download remote file without read it
#2

[eluser]SpooF[/eluser]
Well theres no way to really skip the memory part, but you can reduce the ammount of memory used. So instead of reading the enitre file into memory and then save it you can read a small portion at a time, saving it to disk along the way.

Code:
function save_file($inPath,$outPath)
{
    $in=    fopen($inPath, "rb");
    $out=   fopen($outPath, "wb");
    while ($chunk = fread($in,8192))
    {
        fwrite($out, $chunk, 8192);
    }
    fclose($in);
    fclose($out);
}

save_file('http://www.someimagesite.com/img.jpg','image.jpg');


Messages In This Thread
How to download remote file without read it - by El Forum - 06-16-2010, 09:32 AM
How to download remote file without read it - by El Forum - 06-16-2010, 12:10 PM
How to download remote file without read it - by El Forum - 06-16-2010, 03:50 PM



Theme © iAndrew 2016 - Forum software by © MyBB