So this is what I am trying to do. Make a folder in the uploads/ folder with the username of the user that is currently logged in. Example: uploads/bob
所以这就是我想要做的。使用当前登录用户的用户名在uploads /文件夹中创建一个文件夹。例如:uploads / bob
if (!file_exists('uploads/username')) {
mkdir('uploads/username'), 0777, true);
}
I have the username stored in $_SESSION['Username']
我将用户名存储在$ _SESSION ['Username']中
3 个解决方案
#1
It's simple. You use string concatenation.
这很简单。您使用字符串连接。
if (!file_exists('uploads/'.$_SESSION['Username'])) {
mkdir('uploads/'.$_SESSION['Username']), 0777, true);
}
#2
mkdir('uploads/' . $_SESSION['Username']), 0777, true);
The above code should work
上面的代码应该可行
#3
How about this as a start in the right direction...
这是一个正确方向的开端......
$username = $_SESSION['Username'];
if (!file_exists("uploads/$username")) {
mkdir("uploads/$username"), 0777, true);
}
#1
It's simple. You use string concatenation.
这很简单。您使用字符串连接。
if (!file_exists('uploads/'.$_SESSION['Username'])) {
mkdir('uploads/'.$_SESSION['Username']), 0777, true);
}
#2
mkdir('uploads/' . $_SESSION['Username']), 0777, true);
The above code should work
上面的代码应该可行
#3
How about this as a start in the right direction...
这是一个正确方向的开端......
$username = $_SESSION['Username'];
if (!file_exists("uploads/$username")) {
mkdir("uploads/$username"), 0777, true);
}