Is it possible to get the remote file size for a list of links, get the file size for each and every one of these links from a array or .txt file?
Asked
Active
Viewed 77 times
0
-
1http://stackoverflow.com/questions/2602612/php-remote-file-size-without-downloading-file Might help you out right here. – Fabian Schneider Feb 11 '14 at 11:10
-
Nope, thanks. I am looking at getting the remote file size of a list of links from an array. – Kirmaan Aboobaker Feb 11 '14 at 14:28
1 Answers
1
hope that below will fit your needs
function remote_file_size($url){
$header = get_headers($url, true);
if (isset($header['Content-Length']))
return (int) $header['Content-Length'];
}

Saddam Abu Ghaida
- 6,381
- 2
- 22
- 29
-
Nope, this isn't doing the trick. I want to get the file size for each link from an array. Say the array has a 100 links, i'd like to get the size of the 100 links each separately. – Kirmaan Aboobaker Feb 11 '14 at 14:23
-
you call the function in a loop, i didnt get it. why its not working – Saddam Abu Ghaida Feb 11 '14 at 14:30
-
-
while you are reading the links you pass it to the function and get the result out of it, it works if the content-length is being specified in the header of the reponse which is set in most of the cases – Saddam Abu Ghaida Feb 11 '14 at 14:34
-
Well I need to pass the function an array full of links and have the size of each link returned back. – Kirmaan Aboobaker Feb 11 '14 at 15:40
-
Well Its not working for me, could you detail to me how I pass an array to the function ? – Kirmaan Aboobaker Feb 11 '14 at 15:46