Forums / Setup & design / How to get the size of a remote file?

How to get the size of a remote file?

Author Message

Marco Zinn

Friday 10 December 2010 10:51:55 am

Hi there,

I'm looking for a way (template operator) to retrieve the size of a remote file. I have the full URL of the file in a text line attribute and I want to create a link in the template to the file. Works nice. Now, i want to display the (remote) file size next to the link.

How can this be done? I did not find a template operator for this yet. Although, there does not seem to exist a PHP function for this. I thought, i could use "filesize" for this (http://php.net/manual/de/function.filesize.php ) and use it throught PHPOperatorList , but this is only intended for local files.

Any idea?

Marco
http://www.hyperroad-design.com

Carlos Revillo

Friday 10 December 2010 11:24:52 am

Maybe you can have a look at some of the comments to filesize function and do a function working like that.

have a look at

http://www.php.net/manual/en/function.filesize.php#92462

Ivo Lukac

Monday 13 December 2010 12:56:11 am

"

Hi there,

I'm looking for a way (template operator) to retrieve the size of a remote file. I have the full URL of the file in a text line attribute and I want to create a link in the template to the file. Works nice. Now, i want to display the (remote) file size next to the link.

How can this be done? I did not find a template operator for this yet. Although, there does not seem to exist a PHP function for this. I thought, i could use "filesize" for this (http://php.net/manual/de/function.filesize.php ) and use it throught PHPOperatorList , but this is only intended for local files.

Any idea?

"

Try it with curl. E.g.. http://snipplr.com/view/29/get-remote-filesize/

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

Marco Zinn

Tuesday 14 December 2010 1:47:55 pm

Thanks for your replies.

So, i read, that currently, there is no built-in or otherwise "easy-to-get" option for this. One would need to write a (simple) template operator for it, right?

Marco
http://www.hyperroad-design.com

Ivo Lukac

Wednesday 15 December 2010 12:31:33 am

"

Thanks for your replies.

So, i read, that currently, there is no built-in or otherwise "easy-to-get" option for this. One would need to write a (simple) template operator for it, right?

"

In short, yes :)

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac