I'm practicing scraping data from some third party sites with an html parser. While I'm looping thru the given tags, I use the mkdir() function to create a new folder that is named after one of the variables that is being used in the loop. My code is as follows:
foreach($s->find('a') as $t)
{
$inner = $t->plaintext;
if(!is_dir("img/ncaa/".$team."")
&& !file_exists("/img/ncaa/".$team."/".substr($inner, 0, 4).".png"))
{
foreach($t->find('img') as $l)
{
$url = $l->src;
}
mkdir("img/ncaa/".$team."");
$img = "/img/ncaa/".$team."/".substr($inner, 0, 4).".png";
file_put_contents($img, file_get_contents($url));
}
}
I get an error message reading: Warning: mkdir() [function.mkdir]: Invalid argument in
When I comment out all of the above code and simply write
mkdir("img/ncaa/Boston Celtics");
That seems to work. I thought for a bit that it may have had something to do with permissions, but it didn't.
Any suggestions?