0

I'm trying to stream a video file from a remote server to a client, and I want to get the size of the content transferred while the client plays the file, is it possible somehow?

$file = 'https://example.com/?rud27pxppu45zk.mp4';

$head = array_change_key_case(get_headers($file, TRUE));
$size = $head['content-length']; // because filesize() won't work remotely

header('Content-Type: video/mp4');
header('Accept-Ranges: bytes');
header('Content-Disposition: inline');
header('Content-Length:'.$size);

readfile($file);

exit;
  • 2
    Does this answer your question? [Remote file size without downloading file](https://stackoverflow.com/questions/2602612/remote-file-size-without-downloading-file) – CyC0der Sep 11 '21 at 17:32
  • also: https://stackoverflow.com/questions/27816849/get-size-of-a-remote-file – CyC0der Sep 11 '21 at 17:33
  • @CyC0der I already have the size as $size from headers. I need to get the size while client streams this file. – Alexandru Popa Sep 11 '21 at 17:34
  • please explain it more – CyC0der Sep 11 '21 at 17:36
  • There is that file on some server, and the code above it's on my server. I want to get the size the client receives from the readfile function, the file it's inline. – Alexandru Popa Sep 11 '21 at 17:40
  • readfile will read all bytes and return it to the bowser by one response header, its not possible or maybe i didn't get what do you mean – CyC0der Sep 11 '21 at 17:51

0 Answers0