Zakachka files through PHP. Economy.

This script is intended for zakachki the removed files on your server from any foreign.

That will allow to save on your entering traffic.

For performance it is enough to type{collect} in a browser the following url:

http: // my.server.ru/getfile.php? name=http: // need.server.ru/need_path/need_file.ext or to pass values through the form.

In the resulted script zakachivaemye files will be located in the catalogue download, but it is possible to pass a name of the catalogue through search.



if (isset ($http_get_vars [' name ']))

{

$fn = $http_get_vars [' name '];

$handle = fopen ($fn, ' rb ');


$contents = " ";

if (! $handle)

echo ' error open source file ';

else

{

while (! feof ($handle))

{

$data = fread ($handle, 8192);

$contents. = $data;

}

fclose ($handle);

// './download / ' it is possible to replace, for example, on $http_get_vars ['path']

$handle = fopen ('./download / '. basename ($fn), 'wb');

if (! $handle)

echo ' error create local file ';

else

{

fwrite ($handle, $contents);

fclose ($handle);

echo ' transfer complete ';

}

}

}

?>


Pay attention!

At opening files by function fopen more correct is use of a key "rb".





© Web Development Company Conkurent, LLC 2008-2009. All rights reserved.