WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
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 Resources
Web Development Content
Internet Security Software
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
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

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 : 12422
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  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
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