added url input in upload form closes #69

This commit is contained in:
Chris
2018-10-19 20:00:08 +02:00
parent abcc7ca654
commit fd401088bb
2 changed files with 55 additions and 1 deletions

View File

@@ -518,4 +518,18 @@ function endswith($string, $test) {
$testlen = strlen($test);
if ($testlen > $strlen) return false;
return substr_compare($string, $test, $strlen - $testlen, $testlen) === 0;
}
function remote_filesize($url) {
static $regex = '/^Content-Length: *+\K\d++$/im';
if (!$fp = @fopen($url, 'rb')) {
return false;
}
if (
isset($http_response_header) &&
preg_match($regex, implode("\n", $http_response_header), $matches)
) {
return (int)$matches[0];
}
return strlen(stream_get_contents($fp));
}