Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

AttachSize

Summary: Get file sizes of attached files
Version: 0.1
Prerequisites: None
Status: Alpha
Maintainer: Nobody, feel free to modify or take over
Categories: Uploads

Questions answered by this recipe

How can I display the size of attached files?

Description

Custom markup to get the file size of attached files

To install this recipe:

  • download Attach:AttachSize.phpΔ
  • copy it to your cookbook directory
  • add in your config.php or farmconfig.php this line:
include_once("$FarmD/cookbook/AttachSize.php");

To use, simply use this markup:

(:attachsize filename.ext:)

Notes

  • File sizes are all returned as the nearest whole number of KB, or the number of bytes below 1KB. It doesn't show MB, but then attachments are generally not that large anyway. Possible future enhancements could improve this.
  • Formatting is hard-coded.

Release Notes

If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".

2009-5-26
0.1: Initial release
2009-6-1
0.2: Cross-group attachment checking, can't get info on existence/size of non-attachments any more

See Also

Contributors

Maxim?

Comments

Note that as it is now, the recipe will allow the presence & size of any file accessible via the PHP script to be determined. To fix, take a look at what HandleDownload() in scripts/upload.php does when downloading an attached file. Also, for a relatively robust file size > string converter, take a look at Attachtable's AttachFilesizeString(), eg. from line 269 of thisΔ. —Eemeli Aro May 27, 2009, at 02:46 AM

The presence & size disclosure vulnerability is now fixed.
I didn't bother with the more involved formatting because (1) uploads over 10MB are highly unlikely (do I really need to format petabytes correctly?) and (2) someone would very quickly come along asking for additional formatting like KiB, "octets", etc. Maxim? 2009-05-27
User notes?: If you use, used or reviewed this recipe, you can add your name. The following format is recognized:
* (+) Optional positive comment. Name, date
* (-) Optional negative comment. Name, date

These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.

Edit - History - Print - Recent Changes - Search
Page last modified on June 12, 2009, at 08:41 AM