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!
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
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
By Damon - November 20, 2013
Hi Jac,
Without actually writing the code and testing it out, I'm not sure what the code needed would be but you could try adding code to this admin template:
/cmsAdmin/lib/menus/default/uploadList.php
around line 105.
We can also write this code for you through consulting. Probably would take about 30 minutes to write the code and test. If you are interested in getting it done by our consulting team, shoot us an email to consulting@interactivetools.com.
Thanks!
Damon Edis - interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
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!
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.
interactivetools.com
Hi
Great now!
Hope the feature could be added in the new release.
Thanks!
Jac