NYCPHP Meetup

NYPHP.org

[nycphp-talk] filesize & download

Allen Shaw ashaw at polymerdb.org
Tue Feb 5 11:07:05 EST 2008


David Krings wrote:
> Aniesh joseph wrote:
>> 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.

Alternatively, you could put a script on example.com that returns the
file size for a named file, so that
http://example.com/getfilesize?file=audio1.mp3 returns a size in bytes.

But the better option is surely to use stat(), if you have php5.

- Allen

-- 
Allen Shaw
slidePresenter (http://slides.sourceforge.net)



More information about the talk mailing list