daxguy Posted August 8, 2010 Share Posted August 8, 2010 I have written a piece of code that create a directories, files on the server using mkdir and touch and also inserts the form data into the table.. the code gets executed and the info gets stored in the database but the part which has the create directories. and files dont work as it doesnt create the directory and files on the server.. do i need to make changes to the php.ini file to enable the mkdir and touch feature to get enabled? as i said the code executes without any error.. I dont know wat to do.. please any help would be appreciated!! thanku Link to comment https://forums.phpfreaks.com/topic/210127-help-with-creating-directories-on-server/ Share on other sites More sharing options...
daxguy Posted August 8, 2010 Author Share Posted August 8, 2010 anyone who can help? Link to comment https://forums.phpfreaks.com/topic/210127-help-with-creating-directories-on-server/#findComment-1096607 Share on other sites More sharing options...
TOA Posted August 8, 2010 Share Posted August 8, 2010 Post the code and we'll do our best Link to comment https://forums.phpfreaks.com/topic/210127-help-with-creating-directories-on-server/#findComment-1096613 Share on other sites More sharing options...
daxguy Posted August 8, 2010 Author Share Posted August 8, 2010 i tried adding file permission to the folder on which the directories and the files were being created.. and it worked 1ce and i dunno wats up with it.. it aint working again the code is $title = $_POST['title']; if(is_dir("news_upload")) { if(is_dir("news_upload/$year")) { if(is_dir("news_upload/$year/$month")) { if(is_dir("news_upload/$year/$month/$day")) { touch("news_upload/$year/$month/$day/$title.php"); } else { mkdir("news_upload/$year/$month/$day"); touch("news_upload/$year/$month/$day/$title.php"); } } else { mkdir("news_upload/$year/$month"); mkdir("news_upload/$year/$month/$day"); touch("news_upload/$year/$month/$day/$title.php"); } } else { mkdir("news_upload/$year"); mkdir("news_upload/$year/$month"); mkdir("news_upload/$year/$month/$day"); touch("news_upload/$year/$month/$day/$title.php"); } } Link to comment https://forums.phpfreaks.com/topic/210127-help-with-creating-directories-on-server/#findComment-1096615 Share on other sites More sharing options...
wildteen88 Posted August 8, 2010 Share Posted August 8, 2010 mkdir can create directories recursively. So your above code can be reduced down to mkdir("news_upload/$year/$month/$day", 0777, true); touch("news_upload/$year/$month/$day/$title.php"); Link to comment https://forums.phpfreaks.com/topic/210127-help-with-creating-directories-on-server/#findComment-1096622 Share on other sites More sharing options...
daxguy Posted August 8, 2010 Author Share Posted August 8, 2010 can i add the file permisson to the touch as well? like touch("news_upload/$year/$month/$day/$title.php",0777, true); ??? Link to comment https://forums.phpfreaks.com/topic/210127-help-with-creating-directories-on-server/#findComment-1096623 Share on other sites More sharing options...
wildteen88 Posted August 8, 2010 Share Posted August 8, 2010 no but you can change a file/folders chmod values using chmod Link to comment https://forums.phpfreaks.com/topic/210127-help-with-creating-directories-on-server/#findComment-1096626 Share on other sites More sharing options...
daxguy Posted August 8, 2010 Author Share Posted August 8, 2010 thnx allottt!! Link to comment https://forums.phpfreaks.com/topic/210127-help-with-creating-directories-on-server/#findComment-1096740 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.