我想使用用户的电子邮件地址自动创建一个文件夹(如果尚不存在)。此操作应在他们上传文件时发生。
解决了。我为可能需要它的任何人更新了此代码。谢谢!
这是我的代码:
if(isset($_POST["checkFile"]) && $_FILES["selectFile"]["name"] != "") {
$target_path_pdf = "uploads/pdfs/$email/";
if ( ! is_dir($target_path_pdf)) {
mkdir($target_path_pdf);
}
$target_path_pdf = $target_path_pdf . str_replace(' ', '_', basename($_FILES["selectFile"]["name"]));
if(move_uploaded_file($_FILES["selectFile"]["tmp_name"], $target_path_pdf)) {
}
else {
$flag = 1;
}
$pdfcaption = $_POST['pdfCaption1'];
}
if(isset($_POST["checkPicture"]) && $_FILES["selectPicture"]["name"] != "") {
$target_path_pic = "uploads/pictures/$email/";
if ( ! is_dir($target_path_pic)) {
mkdir($target_path_pic);
}
$target_path_pic = $target_path_pic . str_replace(' ', '_', basename($_FILES["selectPicture"]["name"]));
if(move_uploaded_file($_FILES["selectPicture"]["tmp_name"], $target_path_pic)) {
}
else {
$flag = 1;
}
$piccaption = $_POST['picCaption1'];
}