How can I download all files of a specific type from a website using PHP?

Posted by CheeseConQueso on Stack Overflow See other posts from Stack Overflow or by CheeseConQueso
Published on 2010-05-05T15:44:22Z Indexed on 2010/05/05 15:48 UTC
Read the original article Hit count: 325

Filed under:
|
|
|
|

I want to get all midi (*.mid) files from a site that's set up pretty simple in terms of directory tree structure. I wish we had wget installed here, but that's another party....

The site is VGMusic.com and the path containing all of the midi files is:

http://www.vgmusic.com/music/console/nintendo/nes/

I tried glob'ing it out, but I suppose that glob only works locally?

Here is what I wrote to try to make it happen (doesn't work.. obviously..):

<?php 
echo 'not a blizzard<br>';
foreach(glob('http://www.vgmusic.com/music/console/nintendo/nes/*.mid') as $filename)
{
    echo $filename.'<br>';
    //$newfile = 'http://www.mydomain.com/nes/'.$filename;
    //copy($filename, $newfile)
}
?>

I tried it also without the http:// in there with no luck.

© Stack Overflow or respective owner

Related posts about php

Related posts about glob