NYCPHP Meetup

NYPHP.org

[nycphp-talk] filesize & download

David Krings ramons at gmx.net
Tue Feb 5 06:57:22 EST 2008


Aniesh joseph wrote:
> I have a web page where it displays the list of audio collection. Some 
> of these audios are stored in another server of mine. I wish to add a 
> 'download' option near to each audios.
> 
> So at the time of download, I want to specify the filesize. But filesize 
> or stat functions of php are not return the size of the audio file, if 
> specifies the absolute url of the audio.
> 
> Can someone suggests any method to find out the size of an audio file 
> such as http://example.com/myaudio.mp3 ?

Based on what php.net states, with PHP5.x and up you can use URLs with stat(). 
HTTP and HTTPS are in the list of supported protocols.

You could also store the file size when you add the MP3 to the system, but 
would need to back fill that information for the existing files.


David



More information about the talk mailing list