jbonnett Posted May 6, 2013 Share Posted May 6, 2013 Ok I have made a script that creates some folders and adds some files to them folders, the scrip successfully does this although I can write to the folder /var/www/users/"username"/photos/original/ but not any of the other folders in the photos e.g. /200x200/ any ideas? <?php /* * paths / names */ $folderName = $_SESSION['reguname']; $uname = $session->username; $path = "users/"; $files_path = "include/user_files/"; $all_files = array("/photos","/photos/original","/photos/200x200","/photos/403x226","/photos/460x460","/photos/200x200","/photos/851x315","/files"); $count = count($all_files); for($i = 0; $i < $count; $i++){ /* * Complete paths */ $register_dir = dirname(dirname(__FILE__)) . "/" . $path . $folderName; $register_dir_files = dirname(dirname(__FILE__)) . "/" . $path . $folderName . $all_files[$i]; $session_dir = dirname(dirname(__FILE__)) . "/" . $path . $uname; $session_dir_files = dirname(dirname(__FILE__)) . "/" . $path . $uname . $all_files[$i]; echo $session_dir_files; $normal_dir = $path . $folderName; $normal_dir_files = $path . $folderName . $all_files[$i]; $files_dir = dirname(dirname(__FILE__)) . "/" . $files_path; $files_dir_files = dirname(dirname(__FILE__)) . "/" . $files_path . $all_files[$i]; /* * Create the folder */ //when register $create_register = mkdir($register_dir, 0777); $create_register_files = mkdir($register_dir_files, 0777); $chmod_register = chmod($register_dir, 0777); $chmod_register_files = chmod($register_dir_files, 0777); //when login $create_login = mkdir($session_dir, 0777); $create_login_files = mkdir($session_dir_files, 0777); $chmod_login = chmod($session_dir, 0777); $chmod_login_files = chmod($session_dir_files, 0777); if(!umask(0) & !$create_register & !umask(umask(0)) || !$chmod_register || !umask(0) & !$create_login & !umask(umask(0)) || !$chmod_login || !umask(0) & !$create_register_files & !umask(umask(0)) || !$chmod_register_files || !umask(0) & !$create_login_files & !umask(umask(0)) || !$chmod_login_files) { echo "Could not create your new folder contact the Administator.<br />"; } /* * Copying files to the folders "users/" and "users/username" */ $cf = array("index.php", "file.php"); foreach($cf as $af){ // Users folder eg "users/username" $f = "$files_dir/$af"; $nf = "$register_dir/$af"; if (!copy($f, $nf)) { echo "Error: could not copy \"$register_dir/$af\" to your user folder<br />"; } // Users folder eg "users/" $f = "$files_dir/$af"; $nf = "$session_dir/$af"; if (!copy($f, $nf)) { echo "Error: could not copy \"$session_dir/$af\" to the users folder<br />"; } // Users folder eg "users/all" $f = "$files_dir/$af"; $nf = "$create_register_files/$af"; if (!copy($f, $nf)) { echo "Error: could not copy \"$register_dir_files/$af\" to the users folder<br />"; } // Users folder eg "users/all" $f = "$files_dir/$af"; $nf = "$session_dir_files/$af"; if (!copy($f, $nf)) { echo "Error: could not copy \"$session_dir_files/$af\" to the users folder<br />"; } // Users folder eg "users/all" $f = "$files_dir/$af"; $nf = "$session_dir_files/$af"; if (!copy($f, $nf)) { echo "Error: could not copy \"$session_dir_files/$af\" to the users folder<br />"; } } } ?> Link to comment https://forums.phpfreaks.com/topic/277711-creating-folders/ Share on other sites More sharing options...
Q695 Posted May 6, 2013 Share Posted May 6, 2013 Use this video: http://www.youtube.com/watch?v=ScXN5mKFtiw Link to comment https://forums.phpfreaks.com/topic/277711-creating-folders/#findComment-1428645 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.