ActaNonVerba1 Posted January 24, 2011 Share Posted January 24, 2011 Hey guys im automatically generating a folder location to place some image files the user has uploaded into. If this folder doesnt exist how can i make it? $target_path_thumbnails = "http://www.worldwidelighthouses.com/Images/".$folderlocation."/".$foldername."/Mini/"; Thats the path style. Danny Quote Link to comment Share on other sites More sharing options...
JonnoTheDev Posted January 24, 2011 Share Posted January 24, 2011 You must use an absolute path, not a URL. $dir = '/home/html/images'; if(!is_dir($dir)) { mkdir($dir,0777); } Quote Link to comment Share on other sites More sharing options...
ActaNonVerba1 Posted January 24, 2011 Author Share Posted January 24, 2011 You must use an absolute path, not a URL. $dir = '/home/html/images'; if(!is_dir($dir)) { mkdir($dir,0777); } Hmm, i just made this. Will do this do what i require? // Where the thumbnail images will be placed $target_path_thumbnails = "../../Images/".$folderlocation."/".$foldername."/Mini/"; if (file_exists($$target_path_thumbnails)) { //Do nothing. } else { mkdir($target_path_thumbnails,0777); } Quote Link to comment Share on other sites More sharing options...
ActaNonVerba1 Posted January 24, 2011 Author Share Posted January 24, 2011 You must use an absolute path, not a URL. $dir = '/home/html/images'; if(!is_dir($dir)) { mkdir($dir,0777); } Hmm, i just made this. Will do this do what i require? // Where the thumbnail images will be placed $target_path_thumbnails = "../../Images/".$folderlocation."/".$foldername."/Mini/"; if (file_exists($$target_path_thumbnails)) { //Do nothing. } else { mkdir($target_path_thumbnails,0777); } Ignoring the additional dollar sign which i have now deleted Quote Link to comment Share on other sites More sharing options...
parino_esquilado Posted January 25, 2011 Share Posted January 25, 2011 Files and directories are different. Quote Link to comment Share on other sites More sharing options...
ActaNonVerba1 Posted January 25, 2011 Author Share Posted January 25, 2011 I tested it, it does work According to the PHP Manual file_exists can be used to check both files and directories 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.