我正在尝试进行 php 上传,该上传将上传到特定文件夹。可以在作为文件夹列表的下拉框旁边选择他们希望上传的文件。这是因为它组织文件。
<?php
session_start();
if(!isset($_SESSION["USER"]["Admin"])){
header("Location: index.html?unath");
}
$folder = mysql_real_escape_string($_POST['loc']);
$target_path = "../../shared/docs/$folder";
$upload2 = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $upload2)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
?>
目前,代码将文件上传到“docs”文件夹而不是 docs/文件夹。相反,它将文件夹名称放在文件前面。例如 - 如果文件夹名为“abc”而我的文件名为 robs.docx,它将上传到主 Docs 文件夹并命名为 abcrobs.docx