Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

PHP – File Size

Posted on August 15, 2013February 23, 2016 By David Kittell
function getsize($file,$type)
{
	$size = filesize("$file");
	if($type = 'Bytes')
	{
		echo $size;
	} elseif($type = 'Kb')
	{
		$kbmath = 1024 * $size;
		echo $kbmath;
	} elseif($type = 'Mb')
	{
		$mbmath = 1024 * $kbmath;
		echo $mbmath;
	}
}
echo getsize('somefile.php','Bytes');

Example:
[insert_php]
function getsize($file,$type)
{
$size = filesize(“$file”);
if($type = ‘Bytes’)
{
echo $size;
} elseif($type = ‘Kb’)
{
$kbmath = 1024 * $size;
echo $kbmath;
} elseif($type = ‘Mb’)
{
$mbmath = 1024 * $kbmath;
echo $mbmath;
}
}
echo getsize(getcwd() . $_SERVER[‘PHP_SELF’],’Bytes’) . ‘ Bytes’;
[/insert_php]

Originally Posted on August 15, 2013
Last Updated on February 23, 2016
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

Code PHP

Post navigation

Previous post
Next post

Related Posts

Azure – CLI – Build Windows/UNIX VM Function (With or without public IP)

Posted on December 19, 2017

In the functions below the VM name is used in all of the pieces to build the VM to simplify documentation. Important Items: As I use a Firewall appliance in Azure I do not set Network Security Groups (NSG). I have a predefined virtual network (VN) and predefined network subnet…

Read More

Ektron Find Replace In UrlAliasManual

Posted on October 23, 2013October 26, 2015

This script will rename manual aliases set xact_abort on declare @currval nvarchar(500) declare @newval nvarchar(500) declare @search nvarchar(500) declare @replace varchar(500) set @search = ‘/Index’ –string to find set @replace = ‘/Default’ –replacement string declare @pos int declare @id bigint begin tran declare curs cursor local fast_forward for select AliasId,AliasName…

Read More

Ektron Framework API – List Folders

Posted on February 3, 2015October 26, 2015

I found this code on the Ektron Developer Center (see link below) that pertained mainly to menus but assisted me in getting a folder drill-down so I could add it into my DMS content widget. Similar to the DMS content widget make sure you setup the proper permissions to the…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • PowerShell - IIS Remove Site
  • Front Page
  • SQLite - Auto-Increment / Auto Generate GUID
  • PowerShell - FTP Upload Directory With Sub-Directories

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • PowerShell - IIS Remove Site
  • SQLite - Auto-Increment / Auto Generate GUID
  • PowerShell - FTP Upload Directory With Sub-Directories
  • Raspberry Pi - Remove Default Apps
  • PowerShell - Change Windows CD/DVD Drive Letter
©2025 David Kittell | WordPress Theme by SuperbThemes