Edit: The new Answer is a bit workaround:
You cannot check Dom Elements Length, BUT, you can make a header request and get the file size from the URL:
<?php function i_hope_this_works( $XmlUrl ) { //lets assume we fk up so we set size to -1 $size = -1; $request = curl_init( $XmlUrl ); // Go for a head request, so the body of a 1 gb file will take the same as 1 kb curl_setopt( $request, CURLOPT_NOBODY, true ); curl_setopt( $request, CURLOPT_HEADER, true ); curl_setopt( $request, CURLOPT_RETURNTRANSFER, true ); curl_setopt( $request, CURLOPT_FOLLOWLOCATION, true ); curl_setopt( $request, CURLOPT_USERAGENT, get_user_agent_string() ); $requesteddata = curl_exec( $request ); curl_close( $request ); if( $requesteddata ) { $content_length = "unknown"; $status = "unknown"; if( preg_match( "/^HTTP\/1\.[01] (\d\d\d)/", $requesteddata, $matches ) ) { $status = (int)$matches[1]; } if( preg_match( "/Content-Length: (\d+)/", $requesteddata, $matches ) ) { $content_length = (int)$matches[1]; } // you can google status qoutes 200 is Ok for example if( $status == 200 || ($status > 300 && $status <= 308) ) { $result = $content_length; } } return $result; } ?>
Now you can get each file size by URL only with
$file_size = i_hope_this_works('yourURLasString')
Johannes Geidel Apr 21 '16 at 6:40 2016-04-21 06:40
source share