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].""); } Link to comment https://forums.phpfreaks.com/topic/210583-help-creating-directory/ 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.) Link to comment https://forums.phpfreaks.com/topic/210583-help-creating-directory/#findComment-1098630 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"; } } Link to comment https://forums.phpfreaks.com/topic/210583-help-creating-directory/#findComment-1098631 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 Link to comment https://forums.phpfreaks.com/topic/210583-help-creating-directory/#findComment-1098636 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 Link to comment https://forums.phpfreaks.com/topic/210583-help-creating-directory/#findComment-1098638 Share on other sites More sharing options...
daxguy Posted August 12, 2010 Author Share Posted August 12, 2010 THNX it just worked great!!! Link to comment https://forums.phpfreaks.com/topic/210583-help-creating-directory/#findComment-1098641 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.