php-如何将文件移动到使用userid创建的文件夹(上传文件)
php-how to move files to the folder created using userid (upload files)
上传后,我将根据唯一的应用程序 ID 创建文件夹。
我在这里面临的问题是,一旦我上传,文件就会上传到受尊重的文件夹之外。
甚至正在创建文件夹。
任何人都可以帮忙吗!!!
$path = $file['name'];
$path_user = '/home/devestctrl/public_html/wp-content/plugins/est_collaboration/Files/'.'/'.$send_id;
if (!file_exists($path_user)) {
if (mkdir( $path_user,0766,false )) {
if (move_uploaded_file($file['tmp_name'],$path_user.$path)) {
echo"inside 2"."<br>";
echo"Your File Successfully Uploaded";
}
}
}
您需要在 $path_user
和 $path
之间添加一个斜线:
$path_user = '/home/devestctrl/public_html/wp-content/plugins/est_collaboration/Files/'.'/'.$send_id;
if (!is_dir($path_user)) {
if (!mkdir($path_user, 0766, false)) {
die('Directory cannot be created'); // handle this exception
}
}
if (move_uploaded_file($file['tmp_name'], $path_user . '/' . $path)) {
// ----- You are missing this slash -------------------^^^------------
echo "inside 2"."<br>";
echo "Your File Successfully Uploaded";
}
删除 est_collaboration/Files/'
和 .$send_id
之间多余的 /
。
最后追加/
。喜欢
$path_user = '/home/devestctrl/public_html/wp-content/plugins/est_collaboration/Files/'.$send_id.'/';
上传后,我将根据唯一的应用程序 ID 创建文件夹。
我在这里面临的问题是,一旦我上传,文件就会上传到受尊重的文件夹之外。
甚至正在创建文件夹。
任何人都可以帮忙吗!!!
$path = $file['name'];
$path_user = '/home/devestctrl/public_html/wp-content/plugins/est_collaboration/Files/'.'/'.$send_id;
if (!file_exists($path_user)) {
if (mkdir( $path_user,0766,false )) {
if (move_uploaded_file($file['tmp_name'],$path_user.$path)) {
echo"inside 2"."<br>";
echo"Your File Successfully Uploaded";
}
}
}
您需要在 $path_user
和 $path
之间添加一个斜线:
$path_user = '/home/devestctrl/public_html/wp-content/plugins/est_collaboration/Files/'.'/'.$send_id;
if (!is_dir($path_user)) {
if (!mkdir($path_user, 0766, false)) {
die('Directory cannot be created'); // handle this exception
}
}
if (move_uploaded_file($file['tmp_name'], $path_user . '/' . $path)) {
// ----- You are missing this slash -------------------^^^------------
echo "inside 2"."<br>";
echo "Your File Successfully Uploaded";
}
删除 est_collaboration/Files/'
和 .$send_id
之间多余的 /
。
最后追加/
。喜欢
$path_user = '/home/devestctrl/public_html/wp-content/plugins/est_collaboration/Files/'.$send_id.'/';