Welcome Guest, Not a member yet? Register   Sign In
Downloading and validating MP3 from URL
#1

[eluser]RS71[/eluser]
Hey

I was wondering if anybody could help me with a question of mine. How could one make the server download a MP3 file from an URL and make sure its valid? What security problems could I possibly face? (URLs come from a third party XML file)

I appreciate any and all help

Cheers
#2

[eluser]Sire[/eluser]
You can check the mime type. See this function also:
http://us3.php.net/manual/en/function.finfo-file.php
#3

[eluser]mddd[/eluser]
I would use the getid3 library from www.getid3.org .
This is a library that will really look into the file itself and find out what encoding it has, how long it is (in seconds), and MUCH more.
Looking at the mime time will not tell you if it is a working mp3, but this library will.

On security: of course you should not execute the file in any way, just analyze it.
And preferably not store it in any place that is directly accessible by the public.
#4

[eluser]Sire[/eluser]
Yes, getid3 library will give much more information about the mp3.

However, fileinfo_file will still tell you if the mp3 is valid. It reads the file, much like the 'file' command on your server and /usr/share/file/magic.mime. It doesn't just use the file extension it looks into the headers of the file. It isn't reading the web headers, which can be faked.




Theme © iAndrew 2016 - Forum software by © MyBB