WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Mobile Dev World

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Remote File Size
Categories : PHP, Filesystem, HTTP, Sockets Click here to Update Your Picture
Gerhard Gerome
Date : Mar 21st 2007
Grade : 1 of 5 (graded 1 times)
Viewed : 7231
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Gerhard Gerome
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

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
Easy upload class
Categories : PHP Classes, Filesystem, HTTP, PHP
Simple pipe delimited file export program that downloads to a local machine
Categories : PHP, Filesystem, Databases, MySQL, HTTP
Force file download
Categories : PHP, Filesystem, HTTP, Program Execution
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
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
Variable serialization and unserialization. Loading and saving variable structures to and from file.
Categories : Arrays, Filesystem, Variables, Strings, PHP
JSON File Upload
Categories : PHP, AJAX, Filesystem
upload function using PHP's FTP abilities.
Categories : PHP, Filesystem, HTML and PHP
Directory TreeView - File Manager & Explorer - FTP - Utility - PHP/HTML -
Categories : PHP, Directories, FTP, Filesystem, HTML and PHP
$REMOTE_HOST does not return a value.
Categories : PHP, Global Variables, HTTP
Function that does language negotiation based on the Accept-Language header, a cookie or host name
Categories : HTTP, PHP, Cookies
Kasskooye($path) tell you the complete size of a folder
Categories : PHP, Algorithms, Utilities, Filesystem