php - Get size of remote file from URL? -
possible duplicate:
php: remote file size without downloading file
i want find size of file php when user enters link of file uploaded on different site. how?
i assume want size of remote file. following php code should trick:
<?php // url file (link) $file = 'http://example.com/file.zip'; $ch = curl_init($file); curl_setopt($ch, curlopt_nobody, true); curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlopt_header, true); curl_setopt($ch, curlopt_followlocation, true); $data = curl_exec($ch); curl_close($ch); if (preg_match('/content-length: (\d+)/', $data, $matches)) { // contains file size in bytes $contentlength = (int)$matches[1]; } ?>
you first need obtain url file which, in relation mediafire , other file sharing websites, need code obtain after satisfying free user waiting period.
Comments
Post a Comment