cooldude832 Posted April 19, 2008 Share Posted April 19, 2008 I'm trying to expand my CMS for ppl who don't want to .htaccess mod it. Meaning that I need physical files in locations instead of using .htaccess and the request URL to use a single php processor. In my admin section I can "move" the physical file via <?php if(!is_file(ROOT.$url)){ $q = "Select Url from `".PAGES_TABLE."` Where PageID = '".$id."'"; $r = mysql_query($q) or die(mysql_error()."<br /><br />".$q); $row = mysql_fetch_assoc($r); if(rename(ROOT.$row['Url'],ROOT.$url)){ $_SESSION['No_Errors'][] = "The file was moved."; } else{ $_SESSION['Errors'][] = "Error moving the file."; } } ?> My only issue is when the directory isn't there I get the error on the rename function. Anyone got a crafty idea to integrate viral directory growth on this? Link to comment https://forums.phpfreaks.com/topic/101798-using-rename-to-move-to-an-uncreated-directory/ Share on other sites More sharing options...
haku Posted April 19, 2008 Share Posted April 19, 2008 Before moving anything, check to see if the directory exists, and if it doesn't, create it: if(!file_exists("directory/subdirectory")) { mkdir("directory/subdirectory"); } Link to comment https://forums.phpfreaks.com/topic/101798-using-rename-to-move-to-an-uncreated-directory/#findComment-520994 Share on other sites More sharing options...
cooldude832 Posted April 21, 2008 Author Share Posted April 21, 2008 it seems so simple I think I'll try it. I was thinking I needed to do something more complex because of the directory structure I have. Link to comment https://forums.phpfreaks.com/topic/101798-using-rename-to-move-to-an-uncreated-directory/#findComment-522785 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.