6 Posts
jera
10 years ago
8
Topic

Hallo,
I have a little question. In my Content Type I have field Upload File (in Back-end). Then I show the name of this file in the front end and the possibility to download this file. But, how can I show the file size of an uploaded file in the front end to the site visitors? I want them to see the size of this file before downloading. I don't want to write it by hand, because I have a list of such files.


Thanks in advance :)

Get a VIP membership
10 years ago
0
Level 1

Hi jera,

In order to display the file size, you can use this code

$cck->get( 'name_of_file_field' )->file_size

in the override position or in a variation.

Regards,
Mehdi

10 years ago
1
Level 1

Hello Jera,
I have looked at your portfolio page. I like what you are doing.

As Mehdi already posted, the field "file_size" holds the data you want.

I have published an example on my FB page, that shows how it's done via typography HTML option
and how you can find out about even more information about fields on demand

https://www.facebook.com/creativeresort.seblod/posts/1509501742631971

You can just type into the HTML variation:
*text*  ( *file_size* )

6 Posts
jera
10 years ago
0
Level 2

Hallo Viktor,

thank you very much!!! it's a perfect method for displaying the file size - easy and clean! Everything works fine :)

178 Posts
Jeka
10 years ago
0
Level 1
10 years ago
1
Level 1

Hi Jera,

Your last post is empty. I can consider your question as solved.

Regards,
Mehdi.

6 Posts
jera
10 years ago
0
Level 2

Hi Mehdi,

an empty post is not mine - it's from Jeka, I do not know who is he (she).

I've solved my problem, thank you all, very very much! :)

137 Posts
root
10 years ago
0
Level 1

Thanks, Mehdi.

Some more info about getting other attribs from a upload file field (and other fields), here

Kind regards.

137 Posts
root
10 years ago
0
Level 1

eehm sorry, thank you Viktor. The solution provided by Mehdi, as he said only works on a override position or template variation. We don't need to touch that things only for get a field attrib.

As Viktor well said, with *file_size*, from the same field html typography, will get the file size.

But, if you want to get the value of this field, from another field (I usually get all the values from a single field if they have the same permissions) you must use:

$cck->getFile_size('your_upload_field');

And so, you can load all fields of content on a hidden position, and call all of them with your own html/seblod snippet on a single field, like this:

<a href="/$cck->getValue('some_field');" title="$cck->getValue('other_field'); - $cck->getValue('another_field');">*value*</a>
Get a VIP membership