daxguy Posted August 12, 2010 Share Posted August 12, 2010 I am trying to create random no. of directories but its always giving this error Warning: mkdir() [function.mkdir]: Invalid argument in C:\xampp\htdocs\gl\movie_process.php on line 173 the code is for(i=0; i<5; i++) { mkdir("".$base."uploads/movies/$year/$month/$title/".$hosting[$i].""); } Quote Link to comment Share on other sites More sharing options...
sbaker Posted August 12, 2010 Share Posted August 12, 2010 Do you need a trailing slash after $base? (e.g. $base."/uploads..."etc) echo ($base."uploads/movies/$year/$month/$title/".$hosting[$i]); to check that the output is a valid URL. (you do not need the empy "" before and after your URL.) Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted August 12, 2010 Share Posted August 12, 2010 You're passing mkdir an invalid path. To see what the path is change your code to $base_folder = "{$base}uploads/movies/{$year}/{$month}/{$title}/" for$(i = 0; $i < 5; $i++) { if(is_dir($base_folder) { $path = "$base_folder/{$hosting[$i]}"; mkdir($path); } else { echo "{$base_folder} is not a directory"; } } Quote Link to comment Share on other sites More sharing options...
daxguy Posted August 12, 2010 Author Share Posted August 12, 2010 I tried both the solutions.. even tried $base_folder = "{$base}uploads/movies/{$year}/{$month}/{$title}/" for$(i = 0; $i < 5; $i++) { if(is_dir($base_folder) { $path = "$base_folder/{$hosting[$i]}"; mkdir($path); } else { echo "{$base_folder} is not a directory"; } } its giving the same error.. dunno wats up with this!! please help Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted August 12, 2010 Share Posted August 12, 2010 For got echo $path in the loop $path = "$base_folder/{$hosting[$i]}"; echo "Crteating the following path: {$path}"; mkdir($path); Post the output here Quote Link to comment Share on other sites More sharing options...
daxguy Posted August 12, 2010 Author Share Posted August 12, 2010 THNX it just worked great!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.