Jump to content

[SOLVED] Track image bandwidth


steviez

Recommended Posts

<?php

$file = $_GET['image'];

// no trailing "/" for the image directory
$imagedir = '.';

$bandwidthused = filesize($imagedir.'/'.$file) or ;

?>

 

This would work if the image is called from the URL like this "http://domain.com/load.php?image=sample.jpg"

 

From there the $bandwidthused var. will store the bandwidth the image used in bytes.

<?php

$file = $_GET['image'];

// no trailing "/" for the image directory
$imagedir = '.';

$bandwidthused = filesize($imagedir.'/'.$file) or ;

?>

 

This would work if the image is called from the URL like this "http://domain.com/load.php?image=sample.jpg"

 

From there the $bandwidthused var. will store the bandwidth the image used in bytes.

 

This would be a unsafe way to do this and shouldn't be used on a production site. Be sure to include some error handling and sanitize your incoming variables.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.