Admin panel field display file size

7 posts by 3 authors in: Forums > CMS Builder
Last Post: November 21, 2013   (RSS)

Hi 

Please kindly see the attachment.

We have upload feature on our site.

How to display file size on admin panel?

Thanks!

-Jax H.

By Damon - November 19, 2013

Hi JH,

To display the file size of an upload image in the admin, you would need to add code to the upload templates in CMS Builder.

This should work but any admin template file may be changed with a future update so it is a good idea to create your own custom changelog with
any changes that you make so they can be redone after upgrading in the future.

You can also output the filesize on the frontend of the size using the PHP filesize function. Here are some links for reference:

http://php.net/manual/en/function.filesize.php
http://johnveldboom.com/posts/17/quick-php-function-to-get-file-sizes-in-kb-mb-gb
http://stackoverflow.com/questions/5501427/php-filesize-mb-kb-conversion

Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Hi Damon 

have no idea how to add the code.

Could you let me know where to modify the code? which file can be modify?

Thanks!

Jac

-Jax H.

Hi

I am trying to add below code on the file

/cmsAdmin/lib/menus/default/uploadList.php

<!--file size --> 
<?php

// outputs e.g. somefile.txt: 1024 bytes

$filename = 'upload';
echo $filename . ': ' . filesize($filename) . ' bytes';

?>
<!--file size -->

Can you kindly tell me which record I can use?

Thanks!

-Jax H.

By Dave - November 21, 2013

Hi JH, 

Note that we don't support custom modifications to the CMS, but give this a try:

Open /cmsAdmin/lib/menus/default/uploadList.php and search for: Filename:

Add the code in red:

<?php et('Filename:'); ?> <?php echo htmlspecialchars(pathinfo($row['filePath'], PATHINFO_BASENAME)); ?>
<?php $bytes = @filesize($row['filePath']); ?>
<?php if ($bytes) { echo formatBytes($bytes); } ?>

Let me know if that works for you.

Dave Edis - Senior Developer
interactivetools.com

Hi

Great now!

Hope the feature could be added in the new release.

Thanks!

Jac

-Jax H.