In my site root I have a directory called uploaded and I have another directory called inc where i store my functions file.
When user registers I want to create a sub-directory inside the uploaded parent directory.
To my knowledge i have to step out of the inc directory using the ../ so i could get into the uploaded directory and successfully create the sub-directory inside using the mkdir()
I tried this but it does me no good:
<?php
$username = "jamesodurojbe";
$root = dirname(__FILE__);
$dir1 = $root . "../uploaded/$username";
if(!is_dir($dir1)){
mkdir($dir1);
}
?>
please help
Use the third parameter of mkdir():
$path = '/path/to/folder/with/subdirectory';
mkdir($path, 0777, true);
In my case I had to step out of the inc direction with the leading
/../uploaded/$username
credit goes to Ryan Vincent
The whole code had to look like:
//create user account directory folder for uploads
$root = dirname(__FILE__);
$dir1 = $root . "/../uploaded/$username";
if(!is_dir($dir1)){
mkdir($dir1);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.