![]() |
Downloading and validating MP3 from URL - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Downloading and validating MP3 from URL (/showthread.php?tid=30223) |
Downloading and validating MP3 from URL - El Forum - 05-06-2010 [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 Downloading and validating MP3 from URL - El Forum - 05-06-2010 [eluser]Sire[/eluser] You can check the mime type. See this function also: http://us3.php.net/manual/en/function.finfo-file.php Downloading and validating MP3 from URL - El Forum - 05-07-2010 [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. Downloading and validating MP3 from URL - El Forum - 05-07-2010 [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. |