I need to download FIRST n bytes (n ~ 1024+^2) from remote file (located on the other server than mine). All must be done via fopen or similar functions and served to user via header function in binary mode. No redirection (Location via header allowed !
How's the best technique of that ?
It should be look like the code below. This code I'm using to retrieve data from the tail of the file :
<?php
@ignore_user_abort();
@set_time_limit(0);
$name ='http://www.remoteserver.org/file.dat';
$part_size = 1048576;
$fp = @fopen($name, 'rb');
@fseek($fp, -$part_size, SEEK_END);
header("Content-Type: application/octet-stream");
header('Content-Disposition: attachment; filename="file_part.dat"');
header("Content-Length: ". $part_size);
@fpassthru($fp);
exit;
?>
TIA4NFO


Sign In
Create Account


Back to top









