|
|
|
|
|
|
|
|
|
| |
This script can be used to find the file size of a remote file.
|
<?php
function getRemoteFileSize($url){
$parsed = parse_url($url);
$host = $parsed["host"];
$fp = @fsockopen($host, 80, $errno, $errstr, 20);
if(!$fp)return false;
else {
@fputs($fp, "HEAD $url HTTP/1.1\r\n");
@fputs($fp, "HOST: $host\r\n");
@fputs($fp, "Connection: close\r\n\r\n");
$headers = "";
while(!@feof($fp))$headers .= @fgets ($fp, 128);
}
@fclose ($fp);
$return = false;
$arr_headers = explode("\n", $headers);
foreach($arr_headers as $header) {
$s = "Content-Length: ";
if(substr(strtolower ($header), 0, strlen($s)) == strtolower($s)) {
$return = trim(substr($header, strlen($s)));
break;
}
}
if($return){
$size = round($return / 1024, 2);
$sz = "KB"; // Size In KB
if ($size > 1024) {
$size = round($size / 1024, 2);
$sz = "MB"; // Size in MB
}
$return = "$size $sz";
}
return $return;
}
//File size of Google Image
echo "Weberdev Logo Size : " . getRemoteFileSize('http://www.weberdev.com/images/BlueLogo150x45.gif');
echo "<br>A large sized Image : " . getRemoteFileSize('http://www.freewallpapers.to/wallpaper1/tiger.jpg');
?> | | |
|
| Remote File Saving with PHP - Download and serve a remote file. The content of the file will be updated at fixed intervals. Categories : PHP, Filesystem, Cache, Sockets, HTTP | | | PHP Domain Availability Checker Categories : PHP, Complete Programs, Regexps, HTTP, Sockets | | | Simple pipe delimited file export program that downloads to a local machine Categories : PHP, Filesystem, Databases, MySQL, HTTP | | | Easy upload class Categories : PHP Classes, Filesystem, HTTP, PHP | | | Force file download Categories : PHP, Filesystem, HTTP, Program Execution | | | Class that allows the PHP developer to create and manage UNIX like password files suitable for use as Apache authentication password files.
Categories : HTTP, PHP, PHP Classes, Filesystem | | | Using php3 to upload files, uploading files, file uploads. Categories : PHP, Filesystem, HTTP | | | How to let a user download a picture by clicking on it instead of needing to right click and Save-As. Categories : HTTP, PHP, HTML and PHP, Filesystem | | | Introduction to Language Files Categories : PHP, Filesystem, Beginner Guides | | | Directory TreeView - File Manager & Explorer - FTP - Utility - PHP/HTML - Categories : PHP, Directories, FTP, Filesystem, HTML and PHP | | | JSON File Upload Categories : PHP, AJAX, Filesystem | | | A flat file counter Categories : PHP, Cookies, Filesystem, Beginner Guides | | | Take multiple text files and do simple formatting on them and add them to a webpage Categories : HTML, Filesystem, PHP | | | Moving folder hierarchy b/w server Categories : PHP, FTP, Filesystem | | | Download manager - A PHP script for adding a download page to any site.It also enables you track the no. of downloads. Categories : PHP, Content Management, Filesystem, Databases, MySQL | |
| |
| |
|