diff options
| author | Peter Lejeck <peter.lejeck@gmail.com> | 2013-11-01 01:53:17 +0100 |
|---|---|---|
| committer | Peter Lejeck <peter.lejeck@gmail.com> | 2013-11-01 01:53:17 +0100 |
| commit | 687b1be63b80a273af9795baac702c7cb62802ac (patch) | |
| tree | d13e726c051be66cd310eda777f818f63914b5e2 /static/classes | |
| parent | 893fbf251d75df3f5ac1d02d704eec288de426c9 (diff) | |
| parent | 72c861f45ff7458698c2016af5982970d7258a05 (diff) | |
Merge branch 'nuck-dev'
Conflicts:
README.md
Diffstat (limited to 'static/classes')
| -rw-r--r-- | static/classes/UploadedFile.class.php | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/static/classes/UploadedFile.class.php b/static/classes/UploadedFile.class.php new file mode 100644 index 0000000..5b7ba9b --- /dev/null +++ b/static/classes/UploadedFile.class.php @@ -0,0 +1,32 @@ +<?php + +class UploadedFile { + /* Public attributes */ + public $name; + public $mime; + public $tempfile; + public $error; + public $size; + + /* Cached checksums */ + private $sha1; + private $crc32; + + /** + * Generates the SHA1 or returns the cached SHA1 hash for the file. + */ + public function get_sha1 () { + if (! $this->sha1) $this->sha1 = sha1_file($this->tempfile); + + return $this->sha1; + } + /** + * Generates the CRC32 or returns the cached CRC32 hash for the file. + */ + public function get_crc32 () { + if (! $this->crc32) $this->crc32 = hash_file('crc32b', $this->tempfile); + + return $this->crc32; + } +} +?> |
